Jump to content
Search Community

ScrollTrigger pin layout breaks on resize

chungeric test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi,

 

I'm quite new to GSAP and am trying the pinning functionality out. But running into some issues when resizing the screen.

Resizing the screen seems to break the layout. It's most apparent if you scroll past the pinned section and resize.

 

I'm pinning a 100vh tall section, setting the end value to +=500%, and animating a timeline of absolutely positioned elements in the center of that section using scrub.

 

Just wondering if I'm doing this the right way or if there is a better way of doing what I'm trying to do.

 

Thanks

See the Pen bGaapmM by chungeric (@chungeric) on CodePen

Link to comment
Share on other sites

I find that 'normal' people (not developers/designers) don't resize their browser, so it isn't really an issue. But if you care about it why don't you listen for the resize of the browser and run the function of your scrollTrigger again when someone does resize their browser.

 

window.addEventListener("resize", yourFunction);
Link to comment
Share on other sites

On 4/4/2022 at 7:53 PM, mvaneijgen said:

I find that 'normal' people (not developers/designers) don't resize their browser, so it isn't really an issue. But if you care about it why don't you listen for the resize of the browser and run the function of your scrollTrigger again when someone does resize their browser.

 

window.addEventListener("resize", yourFunction);

 

On the newest version of Safari on iOS the address bar will retract and expand depending on whether the user is scrolling up or down - triggering a resize event every time a user changes scroll directions. So, yeah... it's definitely an issue.

  • Like 1
Link to comment
Share on other sites

Hi Surgeon Samuel,

 

Have you tried the new normalizeScroll feature and ignoreMobileResize?

 

 

Also, the latest version of Safari supports the new small, large, and dynamic viewport units, which can help in creating layouts that won't resize. 

 

https://caniuse.com/viewport-unit-variants

https://www.bram.us/2021/07/08/the-large-small-and-dynamic-viewports/

 

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