-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fixed dom event coordinates for scaled container #10096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When map container belongs to a CSS transformed tree, the `getBoundingClientRect()` based solutions report incorrect coordinates. This change accounts for scale during DOM events processing and fixes mapbox#6079 This solution would not work for the cases when css transform includes rotation or skew. But should serve as a decent band-aid for the case of simple scaling.
I'm trying to fix the unit tests, but on my osx I'm getting |
Ah, I think my webgl issues are due to node
Checking on |
@ryanhamley can you please check this one? It avoids using |
thanks @kawsndriy, fix works great. |
Friends, can you please check this out? |
Hi @kawsndriy sorry for the delay. We're working on some deadlines right now and most other work has been put on the back burner. I will try to give this a thorough review on Thursday or Friday of this week. |
@kawsndriy if you still want to contribute this, you'll need to sign our new Contributor License Agreement. I'm going to close this as stale but if you sign the CLA, we can re-open it. |
I was waiting for excited news about this issue :'( |
No judgement on this PR. We'll be happy to re-open and review it once the CLA is signed or if anyone else wants to take up this work. |
CLA signed. Please consider reopening @ryanbaumann |
@kawsndriy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! Thanks for the contribution. I think it's fine that it only handles scale
at this point since that's likely to be the most common transform used on maps.
So happy to see this go in, thanks again for the work @kawsndriy |
// Note: `el.offsetWidth === rect.width` eliminates the `0/0` case. | ||
const scaling = el.offsetWidth === rect.width ? 1 : el.offsetWidth / rect.width; | ||
return new Point( | ||
(e.clientX - rect.left) * scaling, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
el.clientLeft/Top is not used anymore in this version, is that correct?
Thanks @kawsndriy this PR pointed me in the right direction 🙌 |
When map container belongs to a CSS transformed tree, the
getBoundingClientRect()
based solutions report incorrectcoordinates.
This change accounts for scale during DOM events processing and fixes #6079
This solution would not work for the cases when css transform includes rotation or skew. But should serve as a decent band-aid for the case of simple scaling.
Launch Checklist
The following items have not been done. Please let me know if these are blockers for the merge.
mapbox-gl-js
changelog:<changelog></changelog>