Object drag delay issue

Posted by Johnny Darvall on Stack Overflow See other posts from Stack Overflow or by Johnny Darvall
Published on 2010-05-23T23:03:19Z Indexed on 2010/05/23 23:11 UTC
Read the original article Hit count: 332

Filed under:

I have this code that drags stuff around perfectly in IE - however in firefox the onmousedown-drag of the object does not immediately drag but shows the no-entry cursor and then after onmouseup the object drags around freely. The object does stop draging on the next onmouseup. The object should only drag in the onmousdown state, while the onmousup call should cancel the drag by making j_OK=0. I think it may have something to do with the image inside...

the object:

    <em style=position:absolute;left:0;top:0;width:32;height:32;display:block>
< img src=abc.gif onmousedown=P_MV(this.parentNode) style=position:absolute;left:0;top:0;width:inherit>
</em>



    function P_MV(t)
{
 p_E=t
 j_oy=parseInt(p_E.style.top)
 j_ox=parseInt(p_E.style.left)
 j_OK=1
 document.onselectstart=function(){return false}
 document.onmousemove=P_MVy
}

function P_MVy(e)
{
 if(j_OK)
 {
  p_E.style.top=(j_FF?e.clientY:event.clientY)-j_y+j_oy
  p_E.style.left=(j_FF?e.clientX:event.clientX)-j_x+j_ox
 }
 return false
} 

© Stack Overflow or respective owner

Related posts about JavaScript