spacer

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

home / experts / dhtml / column7
Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source
Logo

Drag & Drop in Explorer 4:
moving and dropping the element


Our grabEl function, for identifying the element, has now taken this form:

The function for moving the element, moveEl, is identical to the Navigator version, conceptually. Again, the properties are different:

Because of the universal mousemove event firing, we first check to see if whichEl is null. If it is it means that we have yet to press the mouse button or there is no draggable element under our mouse. In both of these cases, the function should return.

If we have an element to move, the function continues. Since the mouse has moved since the mousedown, we must calculate our new position. We assign this new position to newX and newY:

Using this new position, we calculate the distance the mouse has moved by subtracting the last documented move (currentx, currentY) from the new one:

We save the new position for use next time the mouse moves, by updating the values of currentX and currentY:

To actually move the element, we increment the pixelLeft and pixelTop properties of its style with the respective mouse distances.

Although not absolutely necessary in every case, we supply a false return value for the event, in case another action has been associated with the event. The false value will cancel any other actions. In our present example, moving the element is the only action associated, but other applications may have more than one.

The complete function:

Our simplest function is the one associated with the end of the drag, dropEl. We simply assign a null value to our element-tracking variable. Since our other functions check for null values, this, in effect cancels the event handling.

Let's look at keeping the dragged element on top and a couple of Explorer-specific features.


Produced by Peter Belesis and

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

webref The latest from WebReference.com Browse >
Working with the DOM Stylesheets Collection · Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Combine BottomCount() with Other MDX Functions to Add Sophistication · Creating a Daemon with Python · The Coming Voice-over-WiMAX Revolution

All Rights Reserved. Legal Notices.
Created: 10/22/97
Revised: 10/22/97

URL: http://www.webreference.com/dhtml/column7/IEmove.html