fonveton Posted February 6, 2023 Share Posted February 6, 2023 Is there a way to detect scrolling stopped while using scrolltrigger. I have an element i'm rotating based on scrolling direction with self.direction but I want that element to return original rotation when scrolling stopped. Is there an event or some other way that I'm having a hard time finding? Link to comment Share on other sites More sharing options...
akapowl Posted February 6, 2023 Share Posted February 6, 2023 There is a 'scrollEnd' event. Quote [...] "scrollEnd" - when any ScrollTrigger-related scroller stops scrolling (when roughly 200ms elapses since the last "scroll" event AND the user doesn't have a pointer/mouse pressed on the document/scrollbar) These events get dispatched globally when any such ScrollTrigger-related event occurs (it is not tied to a particular instance). ScrollTrigger.addEventListener("scrollEnd", () => console.log("scrolling ended!")); https://greensock.com/docs/v3/Plugins/ScrollTrigger/static.addEventListener() 1 Link to comment Share on other sites More sharing options...
fonveton Posted February 6, 2023 Author Share Posted February 6, 2023 Thank you. Is there a way to apply this to a specific scrolltrigger which is inside a gsap.timeline? Link to comment Share on other sites More sharing options...
elegantseagulls Posted February 6, 2023 Share Posted February 6, 2023 I think you could also use getVelocity and check if that's 0 inside the scrollTrigger object: https://greensock.com/docs/v3/Plugins/ScrollTrigger/getVelocity() 1 Link to comment Share on other sites More sharing options...
Solution akapowl Posted February 6, 2023 Solution Share Posted February 6, 2023 53 minutes ago, fonveton said: Is there a way to apply this to a specific scrolltrigger which is inside a gsap.timeline? Judging from the descripiton in the docs, I don't think so, as it says that those are global events. 2 hours ago, fonveton said: I have an element i'm rotating based on scrolling direction with self.direction but I want that element to return original rotation when scrolling stopped. Based on that description of yours, maybe on of these threads below can help. If they don't, a minimal demo of your scenario would be really helpful. 1 Link to comment Share on other sites More sharing options...
fonveton Posted February 7, 2023 Author Share Posted February 7, 2023 Thanks again. This solved my problem. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now