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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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 >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint