View Full Version : Action On MouseUp (Drag And Drop)
06-19-2010, 03:00 AM
I Have A Drag And Drop Script Along With A Simple Script To Make Things Appear And Disappear Bt Using This Line: ShowHide('Table'); return false;
I Want to Make It So That When I Drag Something over a Div, More Preferably a Table or an Image and Then Let Go of Your Mouse (onMouseUp) It Makes the Object Disappear Or Have An Action Happen
Alright, I wrote this a while ago and This Time I'll Be More Clear And Simple.
I Want To Make It So That If A Div Hovers Over A Table By Drag And Drop And You Drop Your Div in The Table An Action happens
06-19-2010, 05:53 AM
Well, in the onMouseUp event you're going to have to figure out if the mouse coordinates are within the boundaries of an element that you care about...
So if you have only one object, say a trash can, then just get the mouse coords and the left, top, width, height values of the trash can and determine if the mouse was inside that (at the time of the onMouseUp event).
If you have multiple elements that you can drop objects onto: Make an array of all the objects. In onMouseUp you get the mouse coords and then loop through your array of all objects, getting the left, top, width, height of each one and detecting if the mouse is inside one of them... then depending on which element it is you can perform the action associated with dropping it on that element (probably store that as your own function on each element).
06-19-2010, 06:02 AM
So Here Is My sad sad Attempt,
//The coordinates Code
how was it?
anyways could you give me the code for the coordinates?
P.S. ah yes! Sooo Useful Thanx Man! Pretty much A Trash Can Was What I Was Aiming For, Thanx
06-19-2010, 06:12 AM
PM me tomorrow and I might have time to give you a bit of code... but honestly I'm not going to build the whole thing for you. Start learning about the DOM and how to get values like offsetwidth/height absoluteleft/top. At that point you'll probably be able to write the code yourself. Well probly not, but you might be able to work with the bit of code I'll give you tomorrow.
06-19-2010, 06:30 AM
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.