When I use mouse wheel to scroll content in div
I want it to scroll by e.g., 30px
each step or each mouse wheel tick w/e is the best solution.
I would prefer performance > ease
i.e. I'm preferring javascript > jquery
So I fiddled some solution of my own, you can see example here
Thanks Tom for leading me to this answer.
JS:
function wheel($div,deltaY){
var step = 30;
var pos = $div.scrollTop();
var nextPos = pos + (step*(-deltaY))
console.log("DelatY: " + deltaY + ", Step: " + step + ", nextPos: " + nextPos);
$div.scrollTop(nextPos);
}
$('#test').bind('mousewheel', function(event, delta, deltaX, deltaY) {
wheel($(this),deltaY);
event.preventDefault();
});
Used libraries:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With