How many pixels are scrolled on a website with a mouse wheel down event?

爱⌒轻易说出口 提交于 2019-12-05 03:43:39

Many mouse drivers let you set the distance scrolled by the mouse wheel, so there is not a standard distance. I'd try your code out for a while and pick a distance that keeps you from scrolling all day but doesn't jump a mile at each scroll. You'll kind of need to "feel" it out. Get friends to give feedback, it helps to let a few hands touch this kind of thing.

I have noted that in Google Chrome - that is 100px per mouse scroll

For Firefox, you have the MozMousePixelScroll event, which reports the number of pixels that should be scrolled in e.detail.

window.addEventListener('MozMousePixelScroll', function(e) {
    console.log(e.detail);
});

For many other browsers, you have the mousewheel event that reports e.wheelDeltaY, but they are not in pixels and you will have to guess the amount to be scrolled.

Also see how SproutCore handles scrolling in their own framework (they're writing their own scrolling view too): http://blog.sproutcore.com/scrolling-in-sproutcore/

You'll need to store the current scroll position before the scroll and then when you detect a scroll get the distance travelled me thinks.

We can controll using javascript. Refer below link. I hope it will help you.

http://deepport.net/archives/javascript-scrolling/

Usually each mouse wheel "tick" corresponds to some configurable (by user) number of pixels.

In Windows for example distance scrolled by each mouse wheel click should be a function of SystemParametersInfo( SPI_GETWHEELSCROLLLINES, ...) parameter.

Here you can find more info on the subject.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!