Juc1 Posted February 18, 2021 Share Posted February 18, 2021 Hi all, I want to say: when image 1 enters the viewport, run the timeline on image 1 when image 2 enters the viewport, run the timeline on image 2 etc But so far I am getting - when image 1 enters the viewport, run the timeline on all the images at the same time. Can anyone please correct my pen? Thanks... See the Pen PobjKPj by Juc1 (@Juc1) on CodePen Link to comment Share on other sites More sharing options...
Solution tailbreezy Posted February 18, 2021 Solution Share Posted February 18, 2021 Just change your trigger and you are good to go. Also you will need some height/spacer at the end because you will not be able to reach the last trigger. trigger: item 5 Link to comment Share on other sites More sharing options...
ZachSaucier Posted February 18, 2021 Share Posted February 18, 2021 tailbreezy is correct. It's actually one of the common ScrollTrigger mistakes which I highly recommend 1 Link to comment Share on other sites More sharing options...
PointC Posted February 18, 2021 Share Posted February 18, 2021 @tailbreezy is getting pretty quick with the answers. Maybe he'll be faster than Zach someday. 2 Link to comment Share on other sites More sharing options...
Juc1 Posted February 18, 2021 Author Share Posted February 18, 2021 awesome, thanks guys 👌 Link to comment Share on other sites More sharing options...
Juc1 Posted February 18, 2021 Author Share Posted February 18, 2021 Just adding the link to the relevant pen: See the Pen QWNqBvL by GreenSock (@GreenSock) on CodePen from 2 Link to comment Share on other sites More sharing options...
Garavani Posted August 28 Share Posted August 28 On 2/18/2021 at 5:15 PM, tailbreezy said: Also you will need some height/spacer at the end because you will not be able to reach the last trigger. What exactly do you mean by that? I am having actually issues with forEach timelines which are triggered too early maybe due to the fact that previous sections are pinned with end: +-400% and stuff like that. Very hard to understand the logic of gsap looking at the browser console when everything is wrapped in these pin spacer containers.… Fact is that sometimes timelines get triggered before the trigger element actually enters the viewport. Link to comment Share on other sites More sharing options...
GSAP Helper Posted August 28 Share Posted August 28 Hello @Garavani I'm sorry to hear about your issues. Unfortunatelly it's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or Stackblitz that demonstrates the issue? Even better would be if you could create a new thread for your question, providing that minimal demo there. Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer. Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo: See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen Using a framework/library like React, Vue, Next, etc.? CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: React (please read this article!) Next Svelte Sveltekit Vue Nuxt Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. Link to comment Share on other sites More sharing options...
Garavani Posted August 28 Share Posted August 28 First of all: great library, great support! Sometimes, though, it is too hard and time consuming to REbuild an issue that most probably will not even persist in a totally new minimal demo environment. I simply hoped that any hint on this “height/spacer” remark could give me an idea. Anyhow, thanks a lot! I will go on doing some research. Link to comment Share on other sites More sharing options...
Garavani Posted August 28 Share Posted August 28 I found the answer to my troubles in the answer of OSUblake in this thread: I was never aware that we need to “sort” the timelines in the code according to the real succession on the site! However, so it becomes hard to do forEach loops with timelines if you have different animations in between them… Let’s say we have in a page layout: 1) section [timelineType1] 2) section “some specific individual timeline” 3) section [timelineType1] 4) section “some other specific individual timeline” 5) section “and another specific individual timeline” 6) section [timelineType1] We’d have to repeat the code (const = gsap…) to be able to place it in the correct order… Link to comment Share on other sites More sharing options...
Cassie Posted August 28 Share Posted August 28 Not sure if there's a question here or if you figured it out? But just incase - That's where refreshPriority comes in From the scrollTrigger docs Quote refreshPriority number - It's VERY unlikely that you'd need to define a refreshPriority as long as you create your ScrollTriggers in the order they'd happen on the page (top-to-bottom or left-to-right) which we strongly recommend doing. Otherwise, use refreshPriority to influence the order in which ScrollTriggers get refreshed to ensure that the pinning distance gets added to the start/end values of subsequent ScrollTriggers further down the page (that's why order matters). See the sort() method for details. A ScrollTrigger with refreshPriority: 1 will get refreshed earlier than one with refreshPriority: 0 (the default). You're welcome to use negative numbers too, and you can assign the same number to multiple ScrollTriggers. 2 Link to comment Share on other sites More sharing options...
Garavani Posted August 28 Share Posted August 28 Thank you Cassie! This helped a lot. In fact I came to this in the docs after I understood where my problem was. And sorry for having stepped in this topic that in reality hadn’t much to do with my problem in the end. So for me it is solved! 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