Share Posted October 14, 2021 I have a centered element on my page and when I resize my browser, the element only moves back to the center as soon as I stop resizing the window. Fonts with viewport-related sizes are changing dynamically. I think this is caused by the pin-spacer over my whole element - is that possible? I noticed that it sets itself a fixed width every time I stop resizing. Changing pinSpacing: true, to pinSpacing: false, does not solve the problem. Is there maybe a way to let the element check the browsers width while resizing the window too? Thanks! Link to comment Share on other sites More sharing options...
Share Posted October 14, 2021 Resizes are debounced for performance. There's really no need to recalculate stuff until the browser size has settled. If you want to listen for resizes you can use add an event listener. https://greensock.com/docs/v3/Plugins/ScrollTrigger/static.addEventListener() 2 1 Link to comment Share on other sites More sharing options...
Author Share Posted October 14, 2021 Thanks, this worked for me: window.addEventListener('resize', function(event){ ScrollTrigger.refresh(); }); Link to comment Share on other sites More sharing options...
Share Posted October 14, 2021 Just echoing this 1 hour ago, OSUblake said: There's really no need to recalculate stuff until the browser size has settled. Listening to the resize event and recalculating during resize is a pointless performance drain in most cases. It's a lot of work for the browser and most people don't even look at the content while they're resizing. It's a really small micro detail that devs obsess over - but it's not really of concern to the average user. 3 Link to comment Share on other sites More sharing options...
Author Share Posted October 14, 2021 Yes that is definitely true, its just for a very specific case Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now