spacer

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

home / experts / dhtml / column9
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

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

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