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
thanks for any help
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 zoneLike 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.
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.
I would definitely try to clamp the value once it’s at or lower than that set point.