How to control scroll increment in Firefox when clicking scroll buttons?

I thought this was due to the CSS height property, but it does not work. How to adjust the scroll amount when pressing the scroll up / down buttons?

+3
source share
3 answers

As far as I know, this is not something you control. However, you can listen to the Javascript onScroll event, and then use the Javascript scroll method to more or less scroll through the page depending on what you wanted. I am not sure how it would look, everything can be a little jerky and confusing for the user. You should also consider whether the user has changed on the page or not.

0

, ( , , ), : . , script , curpos.

0

You cannot directly control the scroll step in Firefox when you click the scroll buttons, but you can use this code:

    //element may be window or a HTML element
    //amount of incrementation should be an integer representing the number of pixels to be scrolled
    //works in all last versions of major browsers

    element.addEventListener(/firefox/i.test(navigator.userAgent) ? 'DOMMouseScroll' : 'mousewheel', function (event) {
    element.scrollTop -= (event.detail ? (event.detail % 2 ? event.detail / -3 : event.detail / -2) : event.wheelDelta / 120) * amount;
event.preventDefault();
    }
0
source

Source: https://habr.com/ru/post/1779957/


All Articles