It returns a delta value, +1 or -1, according to scroll direction.
Test :
1: up
Meanwhile, check the original script.
It needs some improvements due to some strange delta values on some browsers.
<html>
<head>
<script type=“text/javascript”>
function handle(delta) {
var s = delta + “: “;
if (delta <0)
s += “down”;
else
s += “up”;
document.getElementById(‘delta’).innerHTML = s;
}
function wheel(event){
var delta = 0;
if (!event) event = window.event;
if (event.wheelDelta) {
delta = event.wheelDelta/120;
if (window.opera) delta = -delta;
} else if (event.detail) {
delta = -event.detail/3;
}
if (delta)
handle(delta);
}
/* Initialization code. */
if (window.addEventListener)
window.addEventListener(‘DOMMouseScroll’, wheel, false);
window.onmousewheel = document.onmousewheel = wheel;
</script>
</head>
<body>
<div id=“delta”>Scroll mouse wheel to see delta here.</div>
</body>
</html>
Do you have an idea about how to use mouse wheel handling? Let me know, and I will (try to) code it.
This entry was posted on Friday, October 9th, 2009 at 10:12 am and is filed under Javascript, Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
You might also like
| Compass Effect in AS3 We show how to create a draggable compass in AS3. We use tweening as our primary tool. There is a number of trigonometric... | New Templates angel animate Added to Flash Banner Online Professional animated angel animated format is called Angel Animate This format has a character for the animated... | Math.random() * Math.random() in AS3 var rand:Number = Math.random() * Math.random() * Math.random(); This is a trick I use when I need... | FullScreen in AS3 Notes: This tutorial covers HTML changes as well. Flash requires an HTML to be in opened in your browser and load... |








