Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Scroll jumps up when enabling #72

Open
iamlinkus opened this issue Nov 23, 2021 · 0 comments
Open

Scroll jumps up when enabling #72

iamlinkus opened this issue Nov 23, 2021 · 0 comments

Comments

@iamlinkus
Copy link

iamlinkus commented Nov 23, 2021

Hey, I'm trying to find out what causes a scroll jump up on a project I'm working on.

I have a focus section which when reached locks the scroll using asscroll.disable and once certain criteria are met (scrolled enough while being locked) unlocks the scroll using asscroll.enable with restore: true.

I'm dependent on the wheel event while the viewport is locked as that's what eventually triggers the unlock, so the user usually is scrolling the mousewheel (or trackpad) the moment when the scroll unlocks.

Now the problem I'm having is that the scroll position (or rather targetPos of asscroll) intermittently jumps upwards. I tried debugging it using breakpoints, but after half a day I did not get anywhere.

I have a theory that because asscroll handles the wheel event, once asscroll is enabled, the wheel event fires before the body height is restored and that probably confuses asscroll as it sets the targetPos (which I'm unable to set manually because it does not have a setter) higher in the page.

I've prepared an example codepen from the forked ASSCroll Basic Demo here: https://codepen.io/linkus/pen/oNeRQga?editors=1111

It's very intermittent, but you can replicate the issue by scrolling slowly down while the viewport is locked.

I've also made a video of the issue (despite me scrolling down only, it jumps up when unlocking):

CleanShot.2021-11-23.at.18.24.26.mp4

@ashthornton if you could have a look it would be extremely helpful! Thanks!

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

No branches or pull requests

1 participant