Jump to content


  • Posts

  • Joined

  • Last visited

navug's Achievements

  1. I'm trying to loop through an array of elements (it could be images or paragraphs) and create the same tween for each one of them. But i wanna do it the right way (the efficient, readable and clean way) In this article (https://css-tricks.com/tips-for-writing-animation-code-efficiently/) the author does some loops examples in tip #7 but he doesn't add all the tweens in a single timeline… So, i’m wondering if this is the way to do it? function createTween(element) { return gsap.from(element,{ //animations }) } function createTimeline() { const images = document.querySelectorAll("img"); const tl = gsap.timeline(); [...images].forEach(element => { tl.add(createTween(element)) }) return tl; } createTimeline() thanks in advance