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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji