I'm using superscrollorama and need to have an animation play once and then never again during the parallax. I could create a function to play the animation but it seems as though it only would work on completion of the parallax. Any thoughts or ideas would be helpful.
controller.addTween('.div', (new TimelineLite()).append([
TweenMax.from( $('.div .hero'), 1,
{css:{left:'1500', top:'-200'}, ease:Quad.easeInOut}),
TweenMax.fromTo($('.div .background'), 1,
{css:{left: -40}, immediateRender:true},
{css:{left: -45}})
]),
100 // scroll duration of tween
);
var oneTime = function(!firstime) {
var firstime;
TweenMax.from( $('.football'), .50, {
css:{left:'1500', top:'-300'}, ease:Quad.easeInOut})
), 500, 500 ;
}
From the top of my head, TweenMax has a method onUpdate which would fire each time one of the properties is valid, and you can even tween any non-standard properties, so with that, you could just call your function, check against a value, and fire oneTime function when it resolves to true, and never do this again ..
It would look something like this:
TweenMax.fromTo($('.div .background'), 1,
{css:{left: -40}, immediateRender:true},
{css:{left: -45}, onUpdate:oneTime,onUpdateParams: $(this).css('left')})
Does it help you this way?