Activate your free membership today | Log-in

Thursday, March 13th, 2008

W3C CSSOM View Module

Category: Browsers, JavaScript, Standards

<p>PPK 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:

JAVASCRIPT:
  1.  
  2. releaseElement: function(e) { // called onmouseup
  3.         var evt = e || window.event;
  4.         dragDrop.draggedObject.style.display = 'none';
  5.         var receiver
  6.                 = document.elementFromPoint(evt.clientX,evt.clientY);
  7.         dragDrop.draggedObject.style.display = '';
  8.  

Related Content:

  • VoiceXML edges closer to standard status
    The Voice Extensible Markup Language (VoiceXML) 2.0 specification has been granted proposed recommendation status by the...
  • What is the W3C doing now?
    Last week I suggested the W3C may be losing its way, but it is still doing some good...
  • Remove 'No documents found' -- W3C standards-compliant
    There have been several tips how to remove 'No documents found' messages in Web views. Here is a more W3C standards-compliant version, which should...
  • W3C hails web-based forms standard
    Web standards body the World Wide Web Consortium has finalised a specification for next-generation web-based forms used...
  • Amaya
    Amaya is the Web browser that was developed by members of the World Wide Web Consortium (W3C) as a practical tool as well as a testing ground for W3C...

Posted by Dion Almaer at 6:05 am
1 Comment

++++-
4.2 rating from 6 votes

1 Comment »

Comments feed TrackBack URI

I recommend reading the editor’s draft instead http://dev.w3.org/csswg/cssom-view/ given that you like reading specifications in the first place :-) It contains some important updates.

Comment by Anne van Kesteren — March 13, 2008

Leave a comment

You must be logged in to post a comment.