elm-maps icon indicating copy to clipboard operation
elm-maps copied to clipboard

Incorrect point of focus on zoom

Open rl-king opened this issue 6 years ago • 1 comments

SSCCE : https://ellie-app.com/3wZ5VGhhZa1/0

When zooming a map thats not positioned at the top left of a document the zoom doesn't follow the cursor position.

Possible cause is the use of clientX and clientY instead of offsetX and offsetY in this module : https://github.com/kennib/elm-maps/blob/master/src/Maps/Internal/Screen.elm#L117

MouseEvent offset info https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/offsetX

rl-king avatar Apr 05 '18 21:04 rl-king

I've looked in to this a bit. Replacing clientX and clientY with offsetX and offsetY does fix the issue. You do have to set pointer-event: none; on the image elements, if you don't the offset gets calculated from one of the images instead of the maps element.

Touch events don't have an offset property so there has to be some sort of fallback decoder and it might be impossible to fix it properly without knowing the relative position of the maps element to te viewport.

rl-king avatar Apr 14 '18 15:04 rl-king