Jump to content
Search Community

getLabelAfter + 1

14four test
Moderator Tag

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

Hi, 

I have a scrolling site featuring 14 different animations with a "navigation dots" in between. I'd like to go to getLabelAfter + 1 when scrolling down (so it plays through the animation and then stops), but then getLabelBefore + 1 (or -1?) when scrolling up so it doesn't run through the "navigation dots", but stops just above the animation.

 

Is this possible? (Hopefully this makes sense.)

 

 

__________________________________________

 

[ go to this label when scrolling up from below ]

 

                           ANIMATION

__________________________________________

                                •

                                •

                                •

                                •

                                •

__________________________________________

 

[ go to this label when scrolling up from below ]

 

                           ANIMATION

 

[ go to this label when scrolling down from above ]

__________________________________________

                                •

                                •

                                •

                                •

                                •

__________________________________________

 

[ go to this label when scrolling up from below ]

 

                           ANIMATION

 

[ go to this label when scrolling down from above ]

__________________________________________

                                •

                                •

                                •

                                •

                                •

Link to comment
Share on other sites

I agree with Dipscom, a demo would greatly help.

 

Are you using ScrollMagic to trigger your animations? From what I understand it supports forward and reverse scrolling out of the box:

 

read this: http://scrollmagic.io/

 

Be sure to watch: 

 

 

The getLabelAfter() method takes in a time parameter so that you can get the next label after any time.

You can use getLabelTime() to assess what label you want to pass in to getLabelAfter() like so:

 

var tl = new TimelineMax();


tl.add("label1", 1)
  .add("label2", 2)
  .add("label3", 3)
  .add("label4", 4)
  .add("label5", 5)
  .add("label6", 6)
  .add("label7", 7);


console.log("what label comes after label4?")
console.log(tl.getLabelAfter(tl.getLabelTime("label4"))) //label5


console.log("what label comes after label6?")
console.log(tl.getLabelAfter(tl.getLabelTime("label6"))) //label7

http://codepen.io/GreenSock/pen/xVNPEp?editors=0010#

 

So once you know the start label and end label you want to tween from and to you can use tweenTo() as Dipscom suggested or tweenFromTo like

tl.tweenFromTo("label4", "label5");
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.
×
×
  • Create New...