Change mouse event to include an X + Y value for client position
Showing
1 changed file
with
12 additions
and
1 deletions
... | @@ -423,7 +423,18 @@ | ... | @@ -423,7 +423,18 @@ |
423 | } | 423 | } |
424 | try { | 424 | try { |
425 | var evt = document.createEvent("MouseEvents"); | 425 | var evt = document.createEvent("MouseEvents"); |
426 | evt.initMouseEvent(type, true, true, window, 1, 1, 1, 1, 1, false, false, false, false, 0, elem); | 426 | |
427 | try { | ||
428 | var pos = elem.getBoundingClientRect(), | ||
429 | center_x = Math.floor((pos.left + pos.right) / 2), | ||
430 | center_y = Math.floor((pos.top + pos.bottom) / 2); | ||
431 | } catch(e) { | ||
432 | var center_x = 1, center_y = 1; | ||
433 | } | ||
434 | |||
435 | evt.initMouseEvent(type, true, true, window, 1, 1, 1, center_x, center_y, false, false, false, false, 0, elem); | ||
436 | |||
437 | |||
427 | // dispatchEvent return value is false if at least one of the event | 438 | // dispatchEvent return value is false if at least one of the event |
428 | // handlers which handled this event called preventDefault; | 439 | // handlers which handled this event called preventDefault; |
429 | // so we cannot returns this results as it cannot accurately informs on the status | 440 | // so we cannot returns this results as it cannot accurately informs on the status | ... | ... |
-
Please register or sign in to post a comment