Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
qqignatqq

The scrolltrigger animation works when the window width changes

Recommended Posts

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

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

 

  • Like 3
Link to comment
Share on other sites

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

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.

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