FireFox onDrag Pagex PageY is always zero; (

Hi, I am using a visual editor where users are allowed to drag and drop images onto a page and drag other images inside these previously dragged images (for example, “add another image”).

I only need the coordinates of the mouse while dragging: the hiliting element, etc. I am doing custom functions based on these coordinates.

The problem is that although in Webkit I can get them with event.clientX and event.clientY, in Firefox (v.16.0.1 OSX) their "copies" pageX and pageY always have a value of zero while dragging and dropping.

However, they are not Zero during mouseMove.

Smart, like me, I did

$ (document) .on ("mouseMove", function (e) {_ PX = e.pageX, _PY = e.pageY})

to always have the last PageX and PageYY, so that I can use them inside the onDrag handler, but ...

OnMouseMove does not work during the operation Drag And Drop :(: (

Is there a way to get Mouse X and Y during DnD? I would not interfere much with my code, since it should (and already works) work on different platforms, but on firefox.

Can someone give me some pointers? Thanx in advance.

+4
source share
1 answer

Sorry, I found the answer here:

How do I get clientX and clientY to work inside my "drag" event handler in Firefox?

I solved it like this:

(___NODRAGEVENT=$.browser.mozilla) && $(document) .on("dragover",function(e) { e=e.originalEvent; ___PAGEX=e.clientX||e.pageX; ___PAGEY=e.clientY||e.pageY; }); 

I am really surprised and confused that onDragOver DOES includes clientX and clientY. Why don't they populate them before the ondrag event?

+5
source

Source: https://habr.com/ru/post/1442612/


All Articles