How do I get clientX and clientY to work inside my “drag” event handler on Firefox?

后端 未结 3 1113
我在风中等你
我在风中等你 2021-01-05 00:13

Mozilla firefox 3.x seems to have a bug when listening to \"ondrag\" event. The event object doesn\'t report the position of the object being dragged, clientX, clientY and o

3条回答
  •  花落未央
    2021-01-05 00:51

    The drag event in HTML 5 is not fully functional in todays browsers. To simulate a drag n drop situation you should use:

    1. Add a onmousedown event, setting a var true.
    2. Add a onmouseup event, setting that var false.
    3. Add a onmousemove event, checking if that var is true, and if it is, move your div according to the coordinates.

    This always worked for me. If you face any problems, get in touch again, I can provide some examples.

    good luck!

提交回复
热议问题