phernand42 Posted September 24, 2020 Share Posted September 24, 2020 Hi Everyone! Trying to figure out how I go about hiding layers in my svg using scrolltrigger. The effect I'm trying to go for is when a user scrolls down on page a new layer is displayed at certain points/triggers (while also keeping original or first layer displayed always). However as you can see from my pen example there are certain layers I'd to hide when scroll gets to a certain trigger, right now they overlap which I kind of expected. I've been reading up on stagger but I'm not sure how I would go about implementing with scrolltrigger. Thanks in advance! See the Pen XWdOdvQ by phernand42 (@phernand42) on CodePen Link to comment Share on other sites More sharing options...
ZachSaucier Posted September 24, 2020 Share Posted September 24, 2020 Hey phernand42. In general it's good to forget about ScrollTrigger (at least conceptually) until things are animating the way you want to then add ScrollTrigger. So how would you do this without ScrollTrigger (i.e. logically)? You'd want to show one layer and hide the previous one each time a section is reached. To do that sort of thing in GSAP it probably makes sense to create a timeline for each section that fades in the new content and fades out the last content (if necessary). As for your code, you're making one of the most common ScrollTrigger mistakes: putting ScrollTriggers in timeline tweens. Doing so doesn't make much sense. Here's how I'd set it up: See the Pen WNwPzJa?editors=0010 by GreenSock (@GreenSock) on CodePen Side notes: We highly recommend putting the duration inside of the vars parameter. Doing so allows you to use GSAP's defaults functionality which is quite handy. In general it's a good idea to use triggers for the start/end of ScrollTriggers. 2 1 Link to comment Share on other sites More sharing options...
phernand42 Posted September 24, 2020 Author Share Posted September 24, 2020 Ahh makes so much sense. Thanks so much for explaining this @ZachSaucier! Also thanks for link to doc, will read that a bit more I can now see the visibility is controlled by autoAlpha within each section. 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