www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Moveable div weird problem in Firefox

  1. #1
    Join Date
    Jun 2009
    Location
    Portugal
    Posts
    3

    resolved [RESOLVED] Moveable div weird problem in Firefox

    I have a script to move a div using the mouse. It works correctly and updates the position onmouse move. However, after the second or third mousedown on it, the div doesn't update its position when I move the mouse but it will update the position onmouseup. I have tested the script in some browsers and apparently this only occurs in Firefox. Looks like it thinks it is an image and then creates that image shadow it usually does and moves it around until mouseup.. If I was not clear enough, you can check what I'm talking about in the page. All the source code is on the .html.

  2. #2
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,689
    try
    Code:
    		<script type="text/javascript">
    			var beforex,beforey,click1x,click1y,diffx,diffy,oldx,oldy;
    			var move = 0;
    			var fstime = 0;
    			function startMove(ev) {
    				move=1;
    				fstime=1;
    				click1x=ev.clientX;
    				click1y=ev.clientY;
     if (!window.event) ev.preventDefault();
     return false;
    			}
    
    			function stopMove(ev) {
    				move=0;
    				fstime=0;
    			}
    
    			function updMove(ev) {
    				if(move==1) {
    					if(fstime==1) {
    						diffx=ev.clientX-click1x;
    						diffy=ev.clientY-click1y;
    					}
    					else {
    						diffx=ev.clientX-beforex;
    						diffy=ev.clientY-beforey;
    					}
    					oldx=pix(el('menu').style.left);
    					oldy=pix(el('menu').style.top);
    					el('menu').style.left=(oldx+diffx)+'px';
    					el('menu').style.top=(oldy+diffy)+'px';
    					beforex=ev.clientX;
    					beforey=ev.clientY;
    					fstime=0;
    				}
     if (!window.event) ev.preventDefault();
     return false;
    			}
    			function el(id) {return document.getElementById(id);}
    			function pix(v) {return parseInt(v.substring(0,v.length-2));}
    		</script>
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Jun 2009
    Location
    Portugal
    Posts
    3
    Many many thanks vwphillips, it is now working how it was supposed.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles