Jump to content
GreenSock

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

prev&next button

Recommended Posts

Hello all!

 

is it possible for someone to show me a prev&next navigation code example using green sock?

 

thank's in advance!

Link to comment
Share on other sites

Unfortunately there are lots of ways to use prev and next all depending on what exactly it is you are navigating. 

 

The following example shows how to use a next button to navigate to the next label in a timeline using TimelineMax's getLabelAfter() method:

 

var next = $("#next"),
    tl = new TimelineMax({paused:true});
    
tl.to("#box1", 0.5, {left:400}, "label0")
  .to("#box2", 0.5, {left:400}, "label1") 
  .to("#box3", 0.5, {left:400}, "label2")
  .add("label3");
  
next.click(function() {
  var nextLabel = tl.getLabelAfter();
  if (nextLabel){
     tl.tweenTo(nextLabel);
  }else{
    //oops! no more labels
    //go to beginning of timeline and the tweenTo next label
     tl.time(0).tweenTo(tl.getLabelAfter());
  }
});

live demo: http://codepen.io/GreenSock/pen/4a6637992d8e2e2d2eefdb916c6ecc04

 

And yes, TimelineMax has a getLabelBefore() method too ;)

 

If you were looking for something else, please fork that codepen demo and provide some code and animation that illustrates your needs.

  • Like 1
Link to comment
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.
×