Jump to content


prev&next button

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

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")
next.click(function() {
  var nextLabel = tl.getLabelAfter();
  if (nextLabel){
    //oops! no more labels
    //go to beginning of timeline and the tweenTo next label

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.