Dumb plain js question

I am stuck on this about month or so, i want to disable scroll when scrollY equals my needed y. The problem is, before scrolling is disabled, if user will scroll little too fast, it would be scrolled some space before scrolling will be finally disabled, i am using Next.js but disable scroll with plain js.
5 Replies
choco
chocoOP10mo ago
thanks for any help
Vincent Udén
Vincent Udén10mo ago
Should the user ever be able to scroll past this y-value? If not you can just use >= instead of ==. Otherwise you will need a tolerance zone
Matt
Matt10mo ago
Like the above, you will probably need to use a >= to get it to work at all. Then you should set y to the desired value right after disabling scroll. Not sure how that will work with the rendering loop though, so you may first see below the scroll for one frame, then jump back, but it may just work too.
choco
chocoOP10mo ago
i tried to use >= but user scrolls somewhat about a second or so before scroll will be disable. It does not matter the way i disable scroll. By overflow: hidden, or e.preventDefault.
Tiamat
Tiamat10mo ago
I would definitely try to clamp the value once it’s at or lower than that set point.
Want results from more Discord servers?
Add your server