Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

jonathanawesome

Members
  • Posts

    3
  • Joined

  • Last visited

jonathanawesome's Achievements

Newbie

Newbie (1/14)

0

Reputation

1

Community Answers

  1. eek...I just realized a did a poor job explaining the issue. Back to the example in my initial post; reverse() wasn't working after already play()ing through the entire timeline and coming to a stop (in my non-example code, I'm preventing a reverse() action until the timeline has played through). I fiddled and fussed and realized maybe I was burying the timeline unnecessarily. This code works and gives me access to reverse() after play() is finished... var box = document.querySelector('.box'); var play = document.querySelector('.play'); var reverse = document.querySelector('.reverse'); var functions = { scale: new TimelineMax({paused: true}) .to(box, .5, {scale: 2}) } play.addEventListener('click', function() { functions.scale.play(); }); reverse.addEventListener('click', function() { functions.scale.reverse(); });
  2. It's likely that I'm missing a core timeline concept. I don't see the immediate reversal. Here's a slightly modified version that works. var box = document.querySelector('.box'); var play = document.querySelector('.play'); var reverse = document.querySelector('.reverse'); var scale = new TimelineMax({paused: true}) .to(box, .5, {scale: 2}); play.addEventListener('click', function() { scale.play(); }); reverse.addEventListener('click', function() { scale.reverse(); });
  3. I've got a number of timeline functions that are set inside of an object so that I can call them programmatically. You click a button with a number as a data attribute and it call a timeline method on one of these functions, like functions.function1.play(). I can get them to play(), but reverse() doesn't work. Am I missing something simple? var box = document.querySelector('.box'); var play = document.querySelector('.play'); var reverse = document.querySelector('.reverse'); var functions = { scale: function() { //console.log(this); var tl = new TimelineMax({paused: true}) .to(box, .5, {scale: 2}) return tl; } } play.addEventListener('click', function() { functions.scale().play(); console.log(functions.scale()); }); reverse.addEventListener('click', function() { functions.scale().reverse(); //alert('hey'); });
×