0

I am trying to write a small script in which I need to capture the mouse position to fire a popup window, regardless of scrolling (that is, if I scroll down or if I press space or pagedown or the down arrow, the position should remain unchanged). However, all the solutions I found including the ones in this "duplicate" tell me to add a listener to mousemove event or/and eventually scroll, and then get the pageX/screenX/clientX property of the event. By the way, for the scroll detection on firefox I have to create the event :

var mousewheelevt=(/Firefox/i.test(navigator.userAgent))"DOMMouseScroll" : "mousewheel";

This event detects the mouse scrolling but not the use of space/pagedown/downarrow.

I am wondering if there exists a solution using the creation of a custom event that I would fire on demand and which would give me the value I want ?

Thanks in advance.

Community
  • 1
  • 1
Damlatien
  • 71
  • 1
  • 6

1 Answers1

0

I found an answer to my problem : given a (stored) mouseevent e :

e.clientX + document.commandDispatcher.focusedWindow.scrollX

is scroll-invariant, regardless on the way I scroll.

Damlatien
  • 71
  • 1
  • 6