I am trying this code to detect if the mouse direction is going up or down:
<html>
<head></head>
<body>
<div style="width: 500px; height: 500px; background: red;"></div>
</body>
</html>
var mY = 0;
$('body').mousemove(function(e) {
mY = e.pageY;
if (e.pageY < mY) {
console.log('From Bottom');
return;
} else {
console.log('From Top');
}
});
However this code doesn't work was i expect. Console log always show "from top"
Any idea ?
demo
The Mouse Efficiency Test is a test to measure your speed and accuracy when moving your mouse. The rule is quite simple - just move the ball along the curve to the other end attached to it. Please make sure you're not moving out of the curve and be as fast as you can.
Sometimes, the reason is simple, though not that obvious – your mouse could start scrolling in the wrong direction because of accumulated dust around the scrolling wheel. Old batteries are another common culprit causing wireless mice to scroll the wrong way. However, most often, the problem lies in the mouse driver.
Click 'Computer' in the bottom left of the screen. Click 'Control Center' from the pop up menu. In the 'Hardware' section of the Control Center, select'Mouse'. In the section entitled 'Mouse Orientation', make sure that the field 'Left Handed Mouse' has an 'x' in the box next to it.
var mY = 0;
$('body').mousemove(function(e) {
// moving upward
if (e.pageY < mY) {
console.log('From Bottom');
// moving downward
} else {
console.log('From Top');
}
// set new mY after doing test above
mY = e.pageY;
});
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