-
Notifications
You must be signed in to change notification settings - Fork 158
offsetX, offsetY are not correct in Firefox, Opera, Chrome mobile #41
Comments
There's strong chance I'm wrong about Chrome Beta for Android having incorrect values but I'm not able to re-test it right now. |
It looks like offsetX and offsetY are deprecated, or non standard event properties.
They can't be set through initMouseEvent, nor in an Event constructor. Therefore, if they are even set correctly, that seems to be a platform decision that I can't replicate in Javascript. |
Totally agree with your findings but sad to learn Figuring out where an event happens relative to the target object is extremely helpful for drawing applications, drag and drop, and probably many other use cases. It's not too difficult to calculate manually, but any extra code is an opening for silly bugs like box model differences. I think this can be closed. |
Actually, this is standardized in CSS OM View: http://www.w3.org/TR/cssom-view/#extensions-to-the-mouseevent-interface We should add these as they're very helpful. |
Agreed we should fix this i'm going to re open this issue |
I believe Firefox only recently implemented these? https://bugzilla.mozilla.org/show_bug.cgi?id=69787 |
These have worked in firefox for a long time. We have used them in the jQuery Mobile swipe events for years and you can see in the original issue above the reporter says firefox is working correctly. However there are some browser issues we work around with them in jQuery Mobile https://github.com/jquery/jquery-mobile/blob/master/js/events/touch.js#L117-L142 |
@patrickhlauke Hmm that bug thread does sound that way though, and re reading the description they say works fine firefox desktop, but below for just "firefox" it says always zero. This is very confusing... |
While this ticket is older, #217 has pretty much the same discussion and a potential solution. Closing this as a duplicate. |
When pointerevents fire the only way to get the location relative to the target element is
offsetX
andoffsetY
.These values appear to be
0
in some browsers.Working correctly:
Wrong values:
Always zero:
Not tested:
The text was updated successfully, but these errors were encountered: