You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be beneficial to support movementX and movementY for MouseEvent and PointerEvent. This MDN page describes MouseEvent.movementX, which PointerEvent also has because it inherits from MouseEvent.
An example use case would be:
I have a rectangle (implemented as a DOM element) on the page and the user can drag the rectangle around.
In order to move the rectangle along with the user's mouse or pointer, I can use event.movementX and event.movementY as the delta values to update the rectangle's position.
It would involve a lot of mess if I use event.clientX and event.clientY instead because you would then have to figure out the mouse's or pointer's position relative to the rectangle.
I wish I could test this behavior with this library. Now, if I use event.movementX in my source code, tests will fail because event.movementX is not provided.
Suggested solution
A straightforward solution can be to extend the type definition PointerCoords to include movementX and movementY and to modify assignPositionInit in createEvent.ts to accept movementX and movementY as function parameters. In this way, we can directly specify movementX and movementY in our tests like
Another possibly better solution would be to calculate movementX and movementY from the previous pointerState which is already something the library keeps track of.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Problem description
It would be beneficial to support
movementX
andmovementY
forMouseEvent
andPointerEvent
. This MDN page describesMouseEvent.movementX
, whichPointerEvent
also has because it inherits fromMouseEvent
.An example use case would be:
event.movementX
andevent.movementY
as the delta values to update the rectangle's position.event.clientX
andevent.clientY
instead because you would then have to figure out the mouse's or pointer's position relative to the rectangle.I wish I could test this behavior with this library. Now, if I use
event.movementX
in my source code, tests will fail becauseevent.movementX
is not provided.Suggested solution
A straightforward solution can be to extend the type definition
PointerCoords
to includemovementX
andmovementY
and to modifyassignPositionInit
increateEvent.ts
to acceptmovementX
andmovementY
as function parameters. In this way, we can directly specifymovementX
andmovementY
in our tests likeAnother possibly better solution would be to calculate
movementX
andmovementY
from the previouspointerState
which is already something the library keeps track of.Additional context
No response
The text was updated successfully, but these errors were encountered: