Halogen SVG: relative mouse location

Hello,
I have this code using Halogen SVG:

svg [height 360.0, width 360.0, viewBox 0.0 0.0 9.0 9.0,
        onClick \e -> DoSomething (clientX e) (clientY e)]
         [...]

This returns the mouse coordinates relative to the client window.
However, I would like the mouse coordinates relative to the SVG in local coordinates, i.e. from 0.0 to 9.0.
I didn’t find any functions for doing that in the doc
Thanks

You are looking for offsetX / offsetY from Web.CSSOM.MouseEvent.

These functions are not part of purescript-web-uievents because they are defined in a different spec CSSOM View Module instead of UI Events.

I found the function by searching MouseEvent -> Int in pursuit, it doesn’t work for everything but it’s always worth a try.

2 Likes