Jump to content
Search Community

ScrollTrigger pinning sections with multiple effects on same page

Andreykch test
Moderator Tag

Recommended Posts

Hi everyone,

I have 4 sections. I need to make transitions between them. The second section should run over the first, and the third on the second as in first demo, but between the third and fourth transition should be like in second demo, when the third section goes to the top and opens the fourth section under it. I don't understand how this effect can be achieved



See the Pen BaowPwo by GreenSock (@GreenSock) on CodePen

 

See the Pen KKpLdWW by GreenSock (@GreenSock) on CodePen

Link to comment
Share on other sites

What have you tried already? We love to see minimal demo's that you made , that way we can see your thought process and thus better help you. Also the best way to learn is to get your hands dirty, so try something on Codepen based on the demo's you've shared and post back here when you're stuck.

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). 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

 

If you're using something like React/Next/Vue/Nuxt or some other framework, you may find StackBlitz easier to use. We have a series of collections with different templates for you to get started on these different frameworks: React/Next/Vue/Nuxt.

 

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

See the Pen yLQmXWP by andreykch (@andreykch) on CodePen


I tried to write a demo, but I couldn't.  The first two sections work well, but then the third should scroll up. The fourth section should be on the layer under the third section and be pinned (like in the demo in the top message). And the fifth section should cover the fourth when scrolling, like the second and first

Link to comment
Share on other sites

Let's take a step back. 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. 

 

I've changed your CSS so that all the elements are on top of each other. Then I've created a timeline and on that timeline I animate all the sections. 

 

See the Pen RwqXLMM?editors=1010 by mvaneijgen (@mvaneijgen) on CodePen

 

Then if the animation is correct to you then it will be time to think about ScrollTrigger, but only then. 

 

See the Pen BaGXwVv?editors=1010 by mvaneijgen (@mvaneijgen) on CodePen

 

Check out the video from the Greensock YouTube channel, it explains the same points, but in video format. 

 

Hope it helps and happy tweening! 

  • Like 2
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...