knalle

TweenLite yoyo/repeat

Recommended Posts

I need to use TweenLite due to space limitations in the project (yay!)

I suspect the TweenLite isn't working because of the Timeline... not sute really :)

Any suggestions on how to yoyo and repeat with TweenLite?

//working TweenMax version
function flapWingsMax() {
  flapTl = new TimelineLite();
  var wl = TweenMax.to("#wing_left", 0.1, {
    scaleY: 0.5,
    repeat: -1,
    skewX: 20,
    transformOrigin:"86px 104px",
    yoyo: true,
    onComplete:reverseTween,
    onReverseComplete:restartTween,
    ease: Sine.easeInOut
  })
  var wr = TweenMax.to("#wing_right", 0.1, {
    scaleY: 0.5,
    skewX: -20,
    repeat: -1,
    transformOrigin:"9px 87px",
    yoyo: true,
    ease: Sine.easeInOut
  })
  flapTl.add(wl, 0);
  flapTl.add(wr, 0);
}


// TweenLite - NOT working
function flapWingsLite() {
  flapTl = new TimelineLite();
  var wl = TweenLite.to("#wing_left", 0.1, {
    scaleY: 0.5,
    skewX: 20,
    transformOrigin:"86px 104px",
    onComplete:reverseTween,
    onReverseComplete:restartTween,
    ease: Sine.easeInOut
  })
  var wr = TweenLite.to("#wing_right", 0.1, {
    scaleY: 0.5,
    skewX: -20,
    transformOrigin:"9px 87px",
    onComplete:reverseTween,
    onReverseComplete:restartTween,
    ease: Sine.easeInOut
  })
  flapTl.add(wl, 0);
  flapTl.add(wr, 0);
  
  function reverseTween() {
    this.reverse();
  }
  function restartTween() {
    this.restart();
  }
}

Share this post


Link to post
Share on other sites

.... seems the solution was to add the two functions to the TimelineLite instead og the two TweenLites:

flapTl = new TimelineLite({onComplete:reverseTween, onReverseComplete:restartTween});
  • Like 3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.