spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / column9
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Logo

The DHTML Lab Jigsaw Puzzle, Part II: IE4 cont'd
grabbing the puzzle pieces


Drag & Drop

We have discussed drag and drop concepts extensively in columns 6 and 7. Complete drag and drop code for Explorer 4 was developed in column 7. Here we will discuss only the modifications necessary for the puzzle.

As you will recall, the drag and drop code for Explorer took this form:

Grabbing the Puzzle or Puzzle Piece

We will modify the grabEl() function in two places. We gave all draggable elements in the puzzle a draggable property. This applies to the puzzle itself and all puzzle pieces that are created. The value of this property is true or false, depending on whether the element should be dragged or not. In the case of the full puzzle, the value is toggled by the drag toggle button in the controls. Puzzle pieces cannot be dragged if they are placed in their correct position in the puzzle. We will be discussing routines to determine this further down. Since we are concerned with a true value for the draggable property, we modify grabEl() to search it through the element heirarchy that exists under the mousedown:

We also make a change in the code that places the dragged element on top of other draggable elements. When the full puzzle is dragged, no puzzle pieces are visible, as it can only be dragged in a solved form. Therefore, the full puzzle element is excluded from the z-index incrementation.

The user can now continue to attempt a solve by moving the piece.


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

All Rights Reserved. Legal Notices.
Created: Nov. 13, 1997
Revised: Jan. 18, 1998

URL: http://www.webreference.com/dhtml/column9/puzzGrab.html