MouseEvent: pageX/Y, offsetX/Y

The MouseEvent spec covers neither event.pageX/pageY nor  
event.offsetX/offsetY. The former specifies event coordinates relative to  
top of document and the latter coordinates relative to the contents of  
nearest scrollable ancestor container.

Simulating either in JavaScript in a way that takes scrolling of any  
scrollable element into account is a bit convoluted, all the 4 major  
engines already support some of this (Gecko lacks support for  
event.offset*, IE for event.page*, Opera and WebKit supports both though  
Opera copies IE's offset* implementation more correctly for elements with  
borders).

I suggest we should include at least event.offsetX/Y in the spec.

Demo:

data:text/html,<html><head><title>event properties</title></head><body><p  
style="position:fixed; left: 250px"></p><div style="height: 2000px;  
width:200px; margin: 10px; border: 10px black solid; overflow:scroll"  
onmousemove="document.body.firstChild.textContent='client*:  
'+event.clientX+'x'+event.clientY+', screen*:  
'+event.screenX+'x'+event.screenY+', offset:  
'+event.offsetX+'x'+event.offsetY+', page:  
'+event.pageX+'x'+event.pageY+', xy: '+event.x+'x'+event.y;"><p  
style="height: 3500px">Test</p></body></html>

-- 
Hallvord R. M. Steen, Core Tester, Opera Software
http://www.opera.com http://my.opera.com/hallvors/

Received on Friday, 2 July 2010 10:19:49 UTC