- From: Gérard Talbot <www-style@gtalbot.org>
- Date: Mon, 11 Apr 2011 18:26:26 -0700
- To: "Tab Atkins Jr." <jackalmage@gmail.com>
- Cc: "www-style list" <www-style@w3.org>
Le Lun 11 avril 2011 14:35, Tab Atkins Jr. a écrit : > Mouse Positioning > ================= > > On a closely related tangent, the mouse events expose .clientX and > .clientY properties which are relative to the viewport. If you're > trying to find the position of the mouse relative to an element (for > example, if you're drawing something to a <canvas> where the mouse > is), you have to find the position of the element relative to the > viewport and subtract the two positions. I think this is a good > candidate for being made easier, so you can just request the mouse > coords relative to an element. Again, all of the boxes of an element > are potential targets for being measured relative to. offsetX and offsetY properties seem to be what you are looking for here (and it is covered by CSSOM spec): reports/returns X/Y mouse coordinate within the target element http://www.gtalbot.org/DHTMLSection/WindowEventsNS6.html or http://www.gtalbot.org/DHTMLSection/PositioningEventOffsetXY.html (you'll need IE6+ or Opera 7+ to view this) > Thoughts? Yes. I suggest you first search a bit tutorials or articles or interactive demos about those properties. I know Peter-Paul Koch has done something. I remember others (Garrett Smith - DHTMLkitchen) having a demo or tutorial, etc. Those properties (evt.layerX, offsetX, scrollX, etc.) have all been tested, demo-ed interactively. Another one: http://www.gtalbot.org/BugzillaSection/Bug189308_ScrollEvent.html And there are bug reports/enhancement requests to implement some like evt.offsetY in Gecko browsers, others into webkit. Gérard -- CSS 2.1 Test suite RC6, March 23rd 2011 http://test.csswg.org/suites/css2.1/20110323/html4/toc.html Contributions to CSS 2.1 test suite http://www.gtalbot.org/BrowserBugsSection/css21testsuite/ Web authors' contributions to CSS 2.1 test suite http://www.gtalbot.org/BrowserBugsSection/css21testsuite/web-authors-contributions-css21-testsuite.html
Received on Tuesday, 12 April 2011 01:26:57 UTC