Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable scrollbar cause scroll behavior laggy #326

Open
meisken opened this issue May 12, 2022 · 12 comments
Open

Enable scrollbar cause scroll behavior laggy #326

meisken opened this issue May 12, 2022 · 12 comments

Comments

@meisken
Copy link

meisken commented May 12, 2022

After I updated to 0.1.24, The flickering was fixed perfectly. But the scroll behavior became so laggy. During the video, you can see the difference after I remove the scrollbar option. It's much smoother.

2022-05-13.02-18-58.mp4

Reproduction code: https://codesandbox.io/s/react-fullpage-js-example-forked-ylxyp2?file=/src/index.js

@alvarotrigo
Copy link
Owner

Do you have any FPS problems?
Try showing the FPS counter in Chrome and see if you see any difference.

From my side, I can't see any neither on the FPS counter nor with my eyes.

Does removing the easing option change anything for you?

@meisken
Copy link
Author

meisken commented May 13, 2022

I made a new comparison video and I enable the frame rendering stats. I'm using Chrome as well. Obviously, I don't have fps problem and there's a delay on the video left side.

My.Video.mp4

@alvarotrigo
Copy link
Owner

I guess that can be expected.
The CSS animation uses CSS 3d transformations which will use hardware acceleration.

The animation when the scroll bar is enabled is performed using JS and the scrollTo function. This won't use hardware acceleration as far as I know.

However, I'll be making some improvements on this so we can keep on testing things out.
I'll be replacing the setTimeout for a requestAnimationFrame to see if you notice any improvement.

I'll keep you posted whenever I have a version you can try.

@meisken
Copy link
Author

meisken commented May 13, 2022

Did 0.1.24 completely change how the scroll works? Before 0.1.24, It doesn't have this performance issue. I'm not sure if the older version uses the scrollTo function as well? The thing is in the older version, the scroll is smooth and the gsap scrollTrigger animation is smooth as well.

@alvarotrigo
Copy link
Owner

alvarotrigo commented May 13, 2022

Can you test it again with the files ont he dev branch?
https://github.com/alvarotrigo/react-fullpage/tree/dev/dist

You can also install the dev branch from npm directly if you prefer:

npm install "https://github.com/alvarotrigo/react-fullpage.git#dev" --save

Note on the dist files you'll find the version 4.0.8 of fullPage.js where I replaced setTimeout for requestAnimationFrame.

@alvarotrigo
Copy link
Owner

alvarotrigo commented May 13, 2022

Did 0.1.24 completely change how the scroll works? Before 0.1.24, It doesn't have this performance issue.

The option fitToSection changed its behavior and will now make use of the CSS scroll snaps feature. Therefore now it is not the window element scrolling but the body. But I don't think this can create performance issues?

The body will now use scroll-snap-type: y mandatory and scroll-behavior: smooth properties. Perhaps this is?

@alvarotrigo
Copy link
Owner

You can try using fitToSection: false and see if this fixes your issue too.

@meisken
Copy link
Author

meisken commented May 13, 2022

fitToSection: false can solve this issue even in the 0.1.24 version. And "requestAnimationFrame version" doesn't change anything.

It seems like it's not a performance issue. Properly, It's because CSS scroll snaps run immediately after the screen is close to the nearby section. which means CSS scroll snaps will be triggered when the screen is about to leave a section or about to enter a section. Eventually, the fullpagejs scroll and CSS scroll snaps will run together. And it causes the screen looks like laggy.

Personally, I think GSAP scroll snap is so much better. GSAP provides so much more control than CSS scroll snaps.

@meisken
Copy link
Author

meisken commented May 13, 2022

delete

@alvarotrigo
Copy link
Owner

Eventually, the fullpagejs scroll and CSS scroll snaps will run together.

I don't think this is what is happening.
fullPage.js has total control over the scroll. Speed, easing effect etc. And CSS snaps is disabled until the scrolling stops.

The only difference is that now we are scrolling the body element instead of the window.

Personally, I think GSAP scroll snap is so much better. GSAP provides so much more control than CSS scroll snaps.

Can you share any examples?
Perhaps we can implement it in a similar way for fullPgae.js.

@meisken
Copy link
Author

meisken commented May 13, 2022

Here's the gsap snap example: https://codepen.io/petebarr/pen/qBOeVoz

Here's the basic: https://www.youtube.com/watch?v=X7IBa7vZjmo&t=891s

doc: https://greensock.com/docs/v3/Plugins/ScrollTrigger. Snap is one of the ScrollTrigger properties.

@alvarotrigo
Copy link
Owner

Here's the gsap snap example: https://codepen.io/petebarr/pen/qBOeVoz

Yeah, they don't seem to be using the CSS snaps property.
They are doing it all on their side like fullPage.js was doing in version 3, although a bit differently.

Perhaps this is the way fullPage.js should go too. The CSS snaps feature creates a bit of trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants