MouseEvent.offsetX and offsetY are only available on the current event, not on all events
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
People
(Reporter: s.marechal, Unassigned)
References
Details
Updated•8 years ago
|
Comment 2•8 years ago
|
||
Comment 3•8 years ago
|
||
Updated•8 years ago
|
Comment 4•8 years ago
|
||
Comment 5•8 years ago
|
||
Comment 7•8 years ago
|
||
Comment 8•8 years ago
|
||
Updated•8 years ago
|
I've also encountered this bug. Here's another jsfiddle that prints the value immediately and after a setTimeout(..., 0):
https://jsfiddle.net/winstonchang/L1kxwsg6/11/
It certainly seems that it shouldn't be returning 0.
Comment 11•4 years ago
|
||
Because of this bug, yesterday I spent a good amount of time wondering "wtf?!". In Chrome it's working perfectly fine:
But for Firefox...
Here is a JSFiddle to test it yourself:
https://jsfiddle.net/marverix/oy7gvatb/13/
Like, I don't understand - why you are "zeroing" those values? Is there a good reason for that? Or specification that says to do so?
My workaround for this bug is that I need manually copy those primitive values to other variables...
Comment 12•4 years ago
|
||
Sorry for double-post, but I see that Markdown Images are not supported... so...
Chrome:
https://i.ibb.co/9WrnXc4/screenshot-2.png
Firefox:
https://i.ibb.co/KN2MWPf/screenshot-3.png
Updated•2 years ago
|
Comment 13•9 months ago
|
||
I think I just duplicated this bug with this report: https://bugzilla.mozilla.org/show_bug.cgi?id=1871988
I will add a vote to this report, feel free to mark my report as a dup of this earlier one.
Comment 14•9 months ago
|
||
But you left this for SEVEN YEARS???
Comment 15•9 months ago
|
||
(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #3)
Or hmm, should Event::GetOffsetCoords return page coords when event is not
being dispatched.
Why should it be a getter? These are fixed values once the event has happened. The event happened at that point inside the target. Just cache the actual offsets and offer them as public read-only properties.
Comment 16•9 months ago
|
||
I see that you refer to the spec:
The offsetX attribute must follow these steps:
If the event’s dispatch flag is set, return the x-coordinate of the position where the event occurred relative to the origin of the padding edge of the target node, ignoring the transforms that apply to the element and its ancestors, and terminate these steps.
Return the value of the event’s pageX attribute.
Don't be so obsessive. Blink and WebKit wisely ignore this.
In this case the spec needs to be changed. There is absolutely no use case for the values dropping to zero.
Description
•