Jump to content
Search Community

ScrollTrigger Reverse Scrolling Effect

msa test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

Greetings everyone,

 

I have recently started to work as a Shopify Developer and I have a task to tackle. The developer before me used ScrollTrigger to animate the Home page. It would display one div (slide) that would cover the full size, and when scrolling, the next div coming from the bottom would overlap the existing one, continuing the scroll this animation would repeat until there were no more slides left. Now the client requested that I have this same animation but in reverse, when scrolling, slides would appear from the top and overlap the existing one. Is this possible with this current JS code, or do I need to make this from scratch?

 

I've managed to find a Post here that has CodePen that shows what is my current animation.

See the Pen XWOxrgO by msa-black (@msa-black) on CodePen

Link to comment
Share on other sites

Hi @msa welcome to the forum!

 

You need to make it from scratch. This uses just the normal scroll behaviour of the browser which scrolls from top to bottom, but ScrollTriggers are created for each section that just pins it in place. 

 

Personally I always like to start with a animation (even for simple things like this), because then when you eventually get the question we want the slides to come from the top (or the left, maybe even a bit diagonal) you can just change the animation and you're golden. 

 

Keep in mind that the best thing to do when working with ScrollTrigger is to remove it! This seems counter intuitive, but ScrollTrigger is just animating something on scroll, so just focus on the animation at first and only when you're happy with the animation add ScrollTrigger back in. This way you can focus on one part at a time and it will save a lot of headache when debugging. 

 

Personally I would start with a timeline, change your CSS so that all the sections are right on top of each other and then animate each section .from() yPercent: -100 and than you just need one ScrollTrigger to get the desired effect


If you're new to GSAP check out this awesome getting started guide https://gsap.com/resources/get-started/ and check out the video below!

 

Hope it helps and happy tweening! 

 

 

Link to comment
Share on other sites

  • Solution

Eh, I had some time to spare...Check it out. I've placed comments in the code to better explain things. I've created two animations one that uses a stagger (commented out) and one that uses a custom animation for each section, checkout how simple this is. ScrollTrigger is commented out, but you can easily turn it on, but it is good to keep in mind that ScrollTrigger is just doing the animation you've created tied to the scrollbar. 

 

Hope it helps and happy tweening! 

 

See the Pen JjxmjrE by mvaneijgen (@mvaneijgen) on CodePen

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

@mvaneijgen Hey, I'm experiencing a bug where the last slide briefly appears for 1-2 seconds before the animation starts and the first slide becomes scrollable. This behavior wasn't intended and creates a jarring visual effect. Any hints what could be a possible issue?

 

Here is my Codepen, and if you refresh the website for 2-3 times, you would see that it shows Yellow section for a split second. And In my real case where I'm showing images as slides, it increases from split second to 1-2 seconds. 

 

See the Pen NWJxWQa by msa-black (@msa-black) on CodePen

 

Any hint would be helpful 🙏

Link to comment
Share on other sites

1 hour ago, mvaneijgen said:

Have you read the following from the learning center?

 

https://gsap.com/resources/fouc

I will read it and the remaining docs for common issues, and will let you know what I managed to do. Even though I should have done it sooner, it's overwhelming with all this information about the library 😅

Hartelijk dank! 

Link to comment
Share on other sites

48 minutes ago, msa said:

it's overwhelming with all this information about the library 😅

Ha I get that, I'd just watched all the videos on the YouTube channel (twice) when starting out. But the flash of unstyled content is just CSS rendering before Javascript gets a change, so that  post gives you a smart way of handling that. 

 

Geen probleem en veel geluk!

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Greetings @mvaneijgen, I've implemented the autoAlpha trick and it's working. But this way, my Slides become transparent (because of opacity), which does not give me the flow I hoped for. Is there a way to handle this issue without affecting the opacity of my Slides?

All help is appreciated 🙏

 

Hartelijk dank! 

Link to comment
Share on other sites

The logic would be the same as the fouc docs explain. Make your site as you want with CSS and then when the JS has loaded .set() your elements how you want them to be for GSAP or you can add a class with JS. That all if for you to decide and you have to find what best suites your project. 

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...