Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    cyx
    cyx is offline
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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;
    }

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try using appropriate events, such as ondragstart, etc.
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •