Jump to content
Search Community

How to make blocks of different heights scroll at different speeds?

qqignatqq test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello. I'm trying to do as on https://mgimo.ru . There are 3 blocks and they are of different heights, but they scroll at different speeds and come to an end at the same time. I tried to do it, but I failed. And for some reason, when you cover a distance of 200%, the scroll height changes.  Can you tell me what to do, that it worked well?

https://jsfiddle.net/d8vhx5jc/1/

Link to comment
Share on other sites

You wouldn't want to animate to different percentages. You'd want to animate each box to yPercent: -100.  You'll also want to set the parent pinned element to overflow:hidden.

 

See the Pen xoMJZx by PointC (@PointC) on CodePen

 

Just FYI — ScrollMagic is not a GreenSock product, but works well with GSAP. I wrote a post about that here:

https://greensock.com/scrollmagic

 

Happy tweening.

  • Like 4
Link to comment
Share on other sites

  • 4 years later...

Hi @tobiase and welcome to the GreenSock forums!

 

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? 

 

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

Hi,

 

A couple of things. First there is no GSAP code in your example. When asking for support always include what you already have tried because we don't have the time resources to build custom solutions for our users.  In this case creating an example was quite simple and quick, but please don't get used to it because most of the times it won't be like this.

 

Second is very odd to see ScrollTrigger being used with native horizontal scroll. In fact is quite uncommon to see any native horizontal scrolling on websites these days. Normally you fake horizontal scroll with vertical scroll, like this but without the snapping

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

 

So I created an example of that with your setup and added a few extra classes in order to pin the rows and add some text to them so you can see how this works:

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

 

Hopefully this helps.

Happy Tweening!

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