Jump to content
Search Community

Scrolltrigger pin "jumps" after expanding collapsible element.

Fredrik Vestin test
Moderator Tag

Go to solution Solved by _Greg _,

Recommended Posts

Hi,

I'm having a problem with pinned objects below expandable objects. As you can see in the codepen the pinning works before you expand the fold out. If you scroll down after expanding it the pin jumps and behaves weird afterwards. What do I do to be able to pin elements below elements that change the height of the page?

See the Pen ZEaYqKg by proxxximity (@proxxximity) on CodePen

Link to comment
Share on other sites

  • Solution

Hi!

you need to refresh ScrollTrigger after css animation was finished. Check ScrollTrigger.refresh()

Also i add markers: true to display result of refresh (just for debug)

Also pin: true is the same like pin: ".pinned-section", by default pin pinning trigger element

 

See the Pen zYPxerO?editors=0010 by gregOnCodePen (@gregOnCodePen) on CodePen

 

 

  • Like 2
Link to comment
Share on other sites

1 hour ago, _Greg _ said:

Hi!

you need to refresh ScrollTrigger after css animation was finished. Check ScrollTrigger.refresh()

Also i add markers: true to display result of refresh (just for debug)

Also pin: true is the same like pin: ".pinned-section", by default pin pinning trigger element

 

 

 

 

 

Thank you! It gets much better with the refresh, but if you scroll directly after clicking you still get a jump (I guess the scrolling occurs before the refresh). Is there any way of getting rid of that too or is it something one has to live with?

Link to comment
Share on other sites

Sounds tricky but the same logic stands.

You'd likely need to call refresh multiple times during the course of that section opening. If you used a GSAP tween to open it instead of a CSS animation (we recommend not mixing the two anyway) you could possibly call scrollTrigger.refresh() in a callback?

 

gsap.to(element, { 
  height: 500,
  onUpdate() { 
    scrollTrigger.refresh()
  } 
});


Not sure whether that would do the job or if it would still jump. Worth a shot? 

Link to comment
Share on other sites

20 hours ago, Cassie said:

Sounds tricky but the same logic stands.

You'd likely need to call refresh multiple times during the course of that section opening. If you used a GSAP tween to open it instead of a CSS animation (we recommend not mixing the two anyway) you could possibly call scrollTrigger.refresh() in a callback?

 

gsap.to(element, { 
  height: 500,
  onUpdate() { 
    scrollTrigger.refresh()
  } 
});


Not sure whether that would do the job or if it would still jump. Worth a shot? 

Thank you for the suggestion! I will try it!

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