Jump to content
Search Community

Multiple horizontal "scollers" in a single pinned element

1amShaw test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

Hello.
I was hoping you could help with the following issue.

 

I have a single element, that houses all of my modules. Unfortunately I cannot change this.

 

Inside of this module container element, I'd like to have two different elements (that are NOT taller than 100vh), that get pinned and scroll left... The first instance on the page works perfectly. however, the second instance happens way too soon. I can see that the markers are not where they should be.

 

Thank you in advance!

 

See the Pen QWmYdWM by 1amShaw (@1amShaw) on CodePen

Link to comment
Share on other sites

  • Solution

Heya! Thanks for the demo.

 

You'll need pinnedContainer for this as the calculations will be off for any scrollTriggers in side that container which are running after this one


See the Pen mdxvRXO?editors=1010 by GreenSock (@GreenSock) on CodePen



 

pinnedContainer Element | String - If your ScrollTrigger's trigger/endTrigger element is INSIDE an element that gets pinned by another ScrollTrigger (pretty uncommon), that would cause the start/end positions to be thrown off by however long that pin lasts, so you can set the pinnedContainer to that parent/container element to have ScrollTrigger calculate those offsets accordingly. Again, this is very rarely needed. (added in 3.7.0)


Alternately you can add some containing wrappers around the animated modules that include the ones before and after (so you don't end up with visual UI gaps) and pin those instead of the main container

See the Pen poLGRaZ?editors=0010 by GreenSock (@GreenSock) on CodePen

 

Hope this helps!

 

Link to comment
Share on other sites

Thank you so much for the fast reply.

 

I'm annoyed with myself because I tried using .pinnedContainer (after reading one of your replies the other day) but only applied it to the first one! 

 

Thanks for the other solution too. My issue with that is that the site I am working on allows the user to choose some preset background colours, which applies a class to the 'module'. Then I use those classes as adjacent sibling combinators, to alter spacing, key lines, etc...  (nightmare!), so wrapping them will cause issues with that.

 

But the first option works great! Thank you again! 

 

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