ngc7293 Posted August 6, 2020 Share Posted August 6, 2020 This is a long-awaited plugin, thanks gsap! Just now I have a question, can the plugin add an event to ensure that ‘trigger’ is triggered when the viewport is moved out,When scrolling up after starting? See the Pen bGpGOxJ by xf-ngc7293 (@xf-ngc7293) on CodePen Link to comment Share on other sites More sharing options...
GreenSock Posted August 6, 2020 Share Posted August 6, 2020 I didn't quite understand your question. If you want to trigger a function when an element leaves the viewport, yes, that's easy: ScrollTrigger.create({ trigger: ".element", onLeave: yourFunction }); Does that answer your question? 1 Link to comment Share on other sites More sharing options...
ngc7293 Posted August 6, 2020 Author Share Posted August 6, 2020 23 minutes ago, GreenSock said: I didn't quite understand your question. If you want to trigger a function when an element leaves the viewport, yes, that's easy: ScrollTrigger.create({ trigger: ".element", onLeave: yourFunction }); Does that answer your question? Sorry my english is poor. I mean, when I set {start:'top 50%'}, when "onLeave" is triggered, "trigger" is in the viewport. I hope that no matter what value is set for "start, end", "trigger" can trigger an event when leaving the viewport. I use this event to reset "trigger" Link to comment Share on other sites More sharing options...
GreenSock Posted August 6, 2020 Share Posted August 6, 2020 I wish I understood your question better. Please don't post in a foreign language (I translated it for you using Google Translate). It seems to work exactly as I would expect: See the Pen a07cf64b24db08dab8ecec64f59312ee?editors=0011 by GreenSock (@GreenSock) on CodePen When the trigger element leaves the viewport, the onLeave function is triggered. Am I missing something? 1 Link to comment Share on other sites More sharing options...
ngc7293 Posted August 6, 2020 Author Share Posted August 6, 2020 6 minutes ago, GreenSock said: I wish I understood your question better. Please don't post in a foreign language (I translated it for you using Google Translate). It seems to work exactly as I would expect: When the trigger element leaves the viewport, the onLeave function is triggered. Am I missing something? Sorry, it seems that it is difficult for me to describe my problem clearly, thanks for your reply 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