Jump to content
Search Community

Jitterish sticky element on scroll(Scrollsmoother)

babis test
Moderator Tag

Recommended Posts

Hi guys, i have made a sticky bar( the white one ) in this page http://btr.radial.website/en/roadtrips/tour1/ , but only in chrome the links and the button are shaking as i scroll the page. What might be the problem. The code is this simple one

const innerNavigation = document.querySelector(
			'.inner-navigation__container'
		)
		if (innerNavigation) {
			ScrollTrigger.create({
				trigger: innerNavigation,
				start: 'top 54px',
				endTrigger: '#accomodation',
				toggleClass: 'active',
				pin: true,
				scrub: true,
				pinSpacing: false,
			})
		}

 

Link to comment
Share on other sites

i Cant reproduce the code right now because of the complexity of the structure and dependecies but its similar to this codepen

See the Pen vYjxVQY by babistsour (@babistsour) on CodePen

here the image on the left in green section is also flickering and shaking when the animation is in progress. But it only happens in chrome. IN firefox its ok.

Link to comment
Share on other sites

Hi,

 

These are two unrelated situations. The top bar jittering could be solved by updating to the latest version. Also you should try the same code without ScrollSmoother and see if you get the same result. There has been several improvements over the past month in the ScrollSmoother plugin so the latest version should be the first thing to try.

 

The jittering in the elements inside the green block is most likely due to the fact that the element's width is being animated, it's entire layout has to be rendered and it's child element positioned on every width change. In the codepen example you provide, if you comment out the ScrollSmoother part and replace scrub: true with scrub: 1.5 in the ScrollTrigger config, you get a similar result. If you look closely, you can see that the green element's width is also jittery when the scrub animation is completing with or without ScrollSmoother.

 

I assume that the top bar in your site doesn't have a width/height or position (left/right/margin/padding) animation happening as the user scrolls up and down right? If it does I would try using a transform instead.

 

Sorry I can't be of more assistance but given the limitations of what we can do with your live example and the fact that the codepen probably works in a different way, the only advice I can offer is what I can think of.

 

Finally please try to update to the latest version of GSAP, ScrollTrigger and ScrollSoother in your app and see if there is any improvement.

 

Happy Tweening!

Link to comment
Share on other sites

Hi Rodrigo, thank you for your answers. I put in the navbar a "will-change: transform" and the problem has gone. As  for the green section, i didnt understand the solution. Do you suggest not to animate the width, but something else. Sorry, noob here..

Link to comment
Share on other sites

Hi,

 

Yeah, if possible avoid animating the width of an element especially since it will cause it's child elements being re-positioned on each change, plus I'm not completely sure but I think Chrome could be rounding the element's width, even if the styles box in dev tools says otherwise, which would be consistent with the jittering.

If there is no way around it and you have no other choice than animating the width of the element, try to keep the position of the elements inside of it regardless of the width or hide them until the width animation is completed and show them after, perhaps making the width animation shorter.

 

Let us know if you have other questions.

 

Happy Tweening!

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