Jump to content
Search Community

Scrolltrigger white space generated by pinned element

angelokeirsebilck test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

Hi All,

 

I am trying to achieve some basic Scrolltrigger functionality with a pinned section while one image is fading in, however I am facing a problem. The small codepen will illustrate my problem/question better.

pinSpacing is set to true so my pinned section does not overlap the next block while the animation runs. This all works fine but the problem is because the section (.Slider) is pinned, it creates a white space. The effect that I want to create is that the green section (.Slider) is pinned at it's place but no white space is created above this section.

Is my approach in the right direction? Or should I try to achieve this in a different way?

Thanks!

See the Pen bGapejV by AngeloKeirsebilck (@AngeloKeirsebilck) on CodePen

Link to comment
Share on other sites

Hi,

Ok, thanks I will need to pin the whole wrapper.

I have an extra question (updated the pen). I made another scrolltrigger on the next block triggering when the top of that block hits top of viewport but the start position is not correct because of the pinned section.

I read in the common mistakes docs that this can happen when you set the scrolltriggers in wrong order but here the second scrolltrigger gets initialized after the first one so this should not be a problem, right?

What is the best way to reposition the starting point?

 

Thanks!

Link to comment
Share on other sites

  • Solution

Hello there Angelo,

 

For any subsequent ScrollTriggers within that same wrapper/pin-spacer you will want to set the pinnedContainer property to have their starts/ends where you'd expect them to be.

 

From the docs:

 

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)
  • Like 3
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...