inputs :
- 1 scroll down event scrolls 100 pixels.
- An HTML element is positioned 5 pixels below the bottom of the page and not on screen.
- A JavaScript function is triggered when at least 1 pixel of the HTML element comes on screen, and it:
- automatically scrolls the page to bring the element fully into view.
- prevents any other scroll events during the animation.
events :
- the user performs a single scroll-down event (referred to as "the scroll event").
expected result :
- After scrolling 6 pixels - where 1px of the element becomes visible - the scroll event should be halted, triggering the automatic scroll by the JavaScript function instead.
actual result :
- Despite successfully preventing additional scroll events, there seems to be some conflict between the initial scroll event and the automatic scroll until the full 100px has been scrolled, resulting in a choppy transition.
I attempted to set "overflow:hidden" on the "body" during the animation, but this did not cancel the ongoing scroll event, which persisted even after the completion of the automatic scroll's animation (especially noticeable when using a laptop trackpad).
Any suggestions? Thank you!
P.S.: I am looking for solutions in pure native JavaScript.