W3C CSSOM View Module
Date : 2008 03 13 Category : Tech & DevelopmentPPK has blogged a critique of the new W3C CSSOM View Module. He is a fan:
W3C published the first working draft of the W3C CSSOM View specification (written by Anne van Kesteren), and I must say I'm very happy with it. Since I was testing stuff anyway I created a new compatibility table for most of the methods and properties specified in this document, and browser compatibility is already excellent.
What does this new module do? "The APIs introduced by this specification provide authors with a way to inspect and manipulate the view information of a document. This includes getting the position of element layout boxes, obtaining the width of the viewport through script, and also scrolling an element."
PPK calls out one special method, elementFromPoint:
This method expects two coordinates and then reports which HTML element is located at these coordinates. This is a godsend for drag-and-drop scripts. If the user drops an element, get the mouse coordinates and use this method to find out which HTML element is located at these coordinates.
One catch: you first have to temporarily hide the dragged element, because otherwise elementFromPoint() would always report the dragged element — after all it itself is the topmost element under the mouse.
I'm going to add this functionality to my Drag and Drop script, but for the moment this seems to be the idea:
PLAIN TEXT JAVASCRIPT:releaseElement: function(e) { // called onmouseup var evt = e || window.event; dragDrop.draggedObject.style.display = 'none'; var receiver = document.elementFromPoint(evt.clientX,evt.clientY); dragDrop.draggedObject.style.display = '';