Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-22-2005, 10:44 PM   PM User | #1
cyx
New to the CF scene

 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
cyx is an unknown quantity at this point
Unhappy contentEditable - drag 'n drop images while following mouse trails

okay. this is a question about contentEditable. As you know, you can drag an image, from around the object that is contentEditable=true and drag it into your editable object. You can drag 'n drop text, images, etc.. I'm trying to create a set of functions that will be triggered as soon as the user tries to drag an image, it will drag the image along side the mouse pointer, until the mouse button is released.

a) I've managed to create the set of functions to triggered the image
trailing after the mouse pointer.
b) My problem arises when the user tries to drag the image, when the mouse
button goes down, the "document.onmousemove = drag" does not function
like it is supposed to!

For example, this code will update the window status bar with the current mouse X axis ONLY WHEN the mouse button goes down, when it goes up, it will stop to update window.status. Now, try to put this code in a page with some text and images. Try to select text, first, and then try to drag it, OR try to drag images. Does the window.status get updated while dragging? NO!
Code:
document.onmousedown=goDown;
document.onmouseup=goUp;

function goDown(e) {
	document.onmousemove = drag;
}

function drag(e) {
	window.status = window.event.clientX;
}

function goUp(e) {
    document.onmousemove = null;
}
cyx is offline   Reply With Quote
Old 03-24-2005, 02:30 PM   PM User | #2
codegoboom
Regular Coder

 
Join Date: Aug 2004
Location: codegoboom@yahoo.com
Posts: 999
Thanks: 0
Thanked 0 Times in 0 Posts
codegoboom is an unknown quantity at this point
Try using appropriate events, such as ondragstart, etc.
__________________
*this message will self destruct in n-seconds*
codegoboom is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:06 PM.


Advertisement
Log in to turn off these ads.