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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business