How to get the offsetX and offsetY for component pointer events

I see that pointer events in Perspective provide access to the coordinates below which seem to all be relative to the document, window or screen. I need the coordinates relative to the target element (component) that was clicked though. In javascript this is offsetX and offsetY. Is there any way to get this in Perspective?

clientX (int | float): The X coordinate in local coordinates.
clientY (int | float): The Y coordinate in local coordinates.
pageX (int | float): The X coordinate relative to the whole document.
pageY (int | float): The Y coordinate relative to the whole document.
screenX (int | float): The X coordinate in global (screen) coordinates.
screenY (int | float): The Y coordinate in global (screen) coordinates.

Not realy.
There seem to be a few more properties hidden in the event, but not all of them (for some unknown reason).
The only way to change that would be creating your own module or asking a feature request and hope igntion does it one day

We’re providing properties of the MouseEvent (not Pointer Event). In looking at the documentation for that event, it seems that although there are indeed offset properties available, those properties are documented as “experimental” and their behavior is “likely to change in the future” (note the beaker). Until they are no longer experimental and we can “guarantee” their behavior, we will not be adding them to Perspective.

1 Like

That is surely a bug in their documentation since offsetX and offsetY have been part of the MouseEvent spec since 2009 and have been supported in every major browser for over a decade. Even according to MDN’s over definition of “experimental”, a feature of is no longer considered experimental if it is supported in two or more major browsers. I will create a PR to update its status and see what they say.

Also, pageX and pageY are implemented in Perspective and are also listed as experimental.

PR here MouseEvent - remove experimental on features and tidy by hamishwillee · Pull Request #10220 · mdn/content · GitHub
There were several other items marked as experimental that are being updated, including pageX and pageY.

@cmallonee Experimental status has now been removed from offsetX and offsetY as well as a few other things. MouseEvent - remove experimental on features and tidy by hamishwillee · Pull Request #10220 · mdn/content · GitHub

1 Like

The (erroneous) experimental status of the properties is irrelevant.
We’re encoding React MouseEvent objects to JSON to send to the backend, and they don’t have offsetX or offsetY properties (for whatever reason):

We could add nativeEvent to the mouse event you’re given, but then you’re subject to cross-browser limitations, which we try pretty hard to avoid in Perspective.