qqignatqq Posted May 3, 2021 Share Posted May 3, 2021 Hello. I know I'm bringing up a closed topic, however recently akapowl posted in the thread https://greensock.com/forums/topic/17300-smooth-page-scroll/?do=findComment&comment=138046&_backrid=70811 and I got an alert since I'm subscribed to the thread. The situation is this: I needed to make a fixed header that reduces its height when scrolling. But a problem appeared: if I change the width of the window (the height does not change), then for some reason the animation is triggered. Here is an example: https://jsfiddle.net/trajwbzh/ Here's a video: https://disk.yandex.ru/i/1B6YRGyO0eIg6A I need your help Link to comment Share on other sites More sharing options...
Shaun Gorneau Posted May 3, 2021 Share Posted May 3, 2021 Hi @qqignatqq, The reason this is happening is because you're forcing ScrollTrigger to recalculate on each onRefresh because the tween is killed. You can just omit the onUpdate call. See the Pen LYxwamG by sgorneau (@sgorneau) on CodePen Hope this helps, Shaun 3 Link to comment Share on other sites More sharing options...
qqignatqq Posted May 3, 2021 Author Share Posted May 3, 2021 51 minutes ago, Shaun Gorneau said: The reason this is happening is because you're forcing ScrollTrigger to recalculate on each onRefresh because the tween is killed. You can just omit the onUpdate call. Sorry for the silly question, but why is onUpdate needed? Won't it make things worse? At the moment I see that everything works, but won't something break in the future? Link to comment Share on other sites More sharing options...
Shaun Gorneau Posted May 3, 2021 Share Posted May 3, 2021 2 hours ago, qqignatqq said: Sorry for the silly question, but why is onUpdate needed? Won't it make things worse? At the moment I see that everything works, but won't something break in the future? Hi @qqignatqq, I'm saying the exact opposite. onUpdate is not necessary to include ... you're never required to define an event callback. This will not break anything in the future. 1 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