Hello, I am very new to GSAP and have two questions: 1) I have got elements that are repeated in different places on the page (.animatedTxt, .animatedImg) and I would like to apply the same animation to them as I'm scrolling down. At the moment it seems to be applying the correct animation only to the second element with the classes above.
/* store animation*/
var controller = new ScrollMagic.Controller();
var tween = new TimelineMax();
tween.insert (TweenMax.staggerFromTo('.storeitem', 1,
{
opacity: 0,
delay: 0.5,
ease: Back.easeInOut,
y: 300
},
{
opacity: 1,
y: 0
},
0.3
)
);
var scene = new ScrollMagic.Scene({ triggerElement: ".storelocator", triggerHook: 'onEnter', offset: 250, reverse:false})
.setTween(tween).addTo(controller);
/*smallImg flying in*/
var tween1 = new TimelineMax()
tween1.insert(TweenMax.staggerFromTo('.animatedImg', 2,
{
opacity: 0,
delay: 0,
ease: Back.easeInOut,
x: -300
},
{
opacity: 1,
x: 0
}
)
);
tween1.insert(TweenMax.staggerFromTo('.animatedTxt', 2,
{
opacity: 0,
delay: 0,
ease: Back.easeInOut,
x: 500
},
{
opacity: 1,
x: 0
}
)
);
// build scene
var sceneSmallImg= new ScrollMagic.Scene({ triggerElement: ".animatedImg", triggerHook: 'onLeave', reverse:false, offset:200})
.setTween(tween1).addTo(controller);
2)
reverse:false
in the first part of my code (store animation) does the job of playing animation once, however, it plays it straight away on page load and ignoring the offset and the triggers.
It also seems to me that a lot of the code is repeated. Is there a way of making it more concise? I would appreciate any help on these. Thanks.