Jump to content
Search Community

using onUpdate when scrubbing upwards with scrolltrigger

buster808 test
Moderator Tag

Recommended Posts

Hi, its for scrolltrigger - change start and end when scrubbing upwards. As my hero goes off screen when scrubbing upwards. Ill do a pen if this doesnt help

 

gsap.timeline({
  scrollTrigger:{
  ease: "none",
  trigger: "#demo",
    start: "top +35%",
    end: "bottom +60%",
  scrub: 0.4,

 

Thanks

Link to comment
Share on other sites

Hi,

 

You mean a different start and end points depending on the scroll direction? If that's what you're looking for, I don't know if that's possible with the current API. It seems that the config() method is intended for other purposes, as start and end values are read only.

 

The only thing I can think of is to re-create the ScrollTrigger instance with the new values using the onLeave and onLeaveBack callbacks.

 

Perhaps @GreenSock or @OSUblake could shed some light on that subject.

 

Happy Tweening!!!

  • Like 1
Link to comment
Share on other sites

Yes thats right Rodrigo Ill try your method thanks.

 

I see this on direction

 

ScrollTrigger.create({
  trigger: ".trigger",
  start: "top center",
  end: "+=500",
  onUpdate: self => console.log("direction:", self.direction)
});

 

Reflects the moment-by-moment direction of scrolling where 1 is forward and -1 is backward.

 

Just dont know how to code the onUpdate.

 

My javascript is basic.
 

Link to comment
Share on other sites

I'm still pretty lost, sorry. Why would you want to change the start/end values? I'm relatively confident that you probably don't actually want to do that and once you explain a bit more about the "why" behind your request, we may be able to offer a much simpler solution. Changing the start/end based on direction sounds like something that'd create some major logic issues, but perhaps I'm misunderstanding. 

 

17 hours ago, buster808 said:

As my hero goes off screen when scrubbing upwards

A minimal demo is worth 10,000 words :)

 

Technically you could create two different ScrollTriggers, and just use onEnter/onLeave callbacks on one, and then onEnterBack/onLeaveBack on the other because those are direction-specific. But again, I have a strong suspicion there's a cleaner solution that'll become apparent once you describe the "why" behind your request and provide that minimal demo. 👍

  • Like 2
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...