spacer
Yehuda Shiran July 18, 2001
Measuring Mousewheel Rotations (IE6)
Tips: July 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
HP to Microsoft: Thanks for Nothing
iPhone Remains Left Out as Android Scores Flash
The Year of Living the OpenSocial
Internet Explorer 6 supports a new event, onmousewheel. The onmousewheel event is triggered when the user rotates the wheel button. The event object can be queried to find all the event's properties. Only the onmousewheel event exposes the wheelDelta property. The wheelDelta property indicates the direction and the length of the wheel rotation. The length is given in a multiple of 120. A negative wheelDelta indicates the wheel has been rotated towards the user. A positive value indicates it was rotated away from the user. Put your mouse on the image below and rotate the wheel button. The image should change its position on the page:

Here is the source code:

<SCRIPT LANGUAGE="JavaScript">
<!--
var verticalDistance = 1;
function shiftUpDown() {
  objImage.style.position = "relative";
  verticalDistance = countRotations(verticalDistance);
  objImage.style.top = verticalDistance * 10;
  return false;
}

function countRotations(addRotations) {
  addRotations += event.wheelDelta/120;   
  return addRotations; 
}
// -->
</SCRIPT>

<IMG ID="objImage" SRC="football.jpg" onmousewheel="shiftUpDown()" WIDTH="400"
HEIGHT="266">


People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script · Book Review: Content Rich
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Gateway Launches New Core i7-powered FX-Series Gaming PCs · Review: Lenovo ThinkPad SL300 · EBay, Alternative Site Holiday Resources for Sellers