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 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Drag-event in IE

    I have a div that I can drag on mousedown. In Firefox the code works as expected. In IE, however, it does not work anymore.

    I noticed that if you put the mousemove event listener on the div that I'm dragging that it will get lost if you move the mouse wildly across the screen. So I decided to put the even on the window.

    Now you can move the mouse as fast as you want in FireFox. In IE, however, it moves a little then stops - not reacting at all.

    Is there some kind of quirk here?

    Thanks a bunch!

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Umm hard for us to tell you without any code. We aren't psychic.

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry - I didn't see this as a code-specific problem. But if I was right I probably wouldn't have to ask for help, LOL. So, upon request:

    Code:
           var dragMe = document.getElmentById('dragger');
    
    
    	function startDrag(e, textValue){
    		var evt = new xEvent(e);
    
    		var ourText = document.createTextNode(textValue);
    		dragMe.appendChild(ourText);
    		dragMe.style.display='inline';
    		
    		if(evt.attachEvent){
    			dragMe.style.top = (evt.clientY -10) + 'px';
    			dragMe.style.left = (evt.clientX  -10)+ 'px';
    		} else {
    
    			dragMe.style.top = (evt.pageY -10) + 'px';
    			dragMe.style.left = (evt.pageX -10)+ 'px';
    		}
    		xAddEventListener(window, 'mousemove', whileDrag, true);
    		xAddEventListener(dragMe, 'mouseup', endDrag, false);
    	}
    
    	function whileDrag(e){
    		//alert('entering');
    		var evt = new xEvent(e);
    		//reposition the div to where we currently are
    		if(evt.attachEvent){
    			dragMe.style.top = (evt.clientY -10) + 'px';
    			dragMe.style.left = (evt.clientX  -10)+ 'px';
    		} else {
    			dragMe.style.top = (evt.pageY -10) + 'px';
    			dragMe.style.left = (evt.pageX -10)+ 'px';
    		}
    	}

    EDIT: I observed that the function whileDrag isn't getting called at all. IE isn't giving me a yellow-triangle-of-death, and if you put an alert statement at the end of startDrag() it fires.
    Last edited by Deltran; 10-19-2005 at 05:13 PM.

  • #4
    New Coder
    Join Date
    Aug 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb

    Hate to double post, however I found a solution.

    IE doesn't like window on listeners - it prefers document.body

    Whatever it wants.
    Thanks for looking - I hope this helps someone out someday at least


  •  

    Posting Permissions

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