-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Correct mouse/touch position for elements scaled via CSS transform #9057
Conversation
How css transform affects |
Good catch, @jingsam. |
Fixes #6079 |
Previous attempt to solve this was discarded in #8017. I tested this PR on iOS Safari and it works as expected. |
9c94661
to
59288e0
Compare
Unfortunately, JSDom doesn't have a layout engine, so our unit tests fail due to division by zero. |
@kkaefer great work. Does it affect performance? |
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 great. I tested it with transform: scale()
, padding and margins all set and it worked as expected. Do you have an idea on how to fix the tests?
We could either mock the getters, but that kind of means we're only testing our mock values. I think a better approach would be to switch unit tests to run in a browser and e.g. use puppeteer on CI to run them. |
59288e0
to
7d19922
Compare
Now that we have selenium tests (#9245), what are the next steps needed to land this PR? |
Write a selenium test that double clicks/taps, or sends mouse wheel events at a particular location and check that the resulting zoom correctly reflects the location when the container is zoomed via CSS. |
@ryanhamley still good for release-d? |
7d19922
to
3209bdc
Compare
@kkaefer I tried to add a Selenium test and it works locally but fails on CI. Do you have any insight into what I might be doing wrong? |
@ryanhamley it could be related to pixel ratio. I think our Selenium tests on CI are running at 1×, while your tests locally are running at 2×. |
Is this good for release-e? @ryanhamley |
@sgolbabaei I need to take a look at this tomorrow or Friday. The Selenium test I wrote fails on CI and I'm not sure how to get it to pass locally and on CI if the problem is the pixel ratio. Looks like it needs to be rebased against master too |
After playing around with this some more, I'm not convinced that this fixes the issue. Or at least, I'm running into some confusing behavior. Compare this demo showing the bug and the behavior in this forked version which uses this branch. The click is correct, but zooming behaves differently. Similarly, in this demo which uses this branch, zooming appears to not work as expected. When I have basically the same set up in a local debug page though, things work as expected. |
After consulting with the team, it looks like @karimnaaji is working on implementing dynamic scaling in a way that would make this change unnecessary. I'm going to close this PR in anticipation of that work being a more robust solution. If we find that the need for this still exists in the future, we can revisit it. |
@ryanhamley @karimnaaji is there any update with regards to dynamic scaling? |
Inspired by #9014, I looked at correcting mouse/touch interaction when the Map is transformed via the CSS
transform: scale()
property. It scales the screen pixel coordinates to logical map coordinates.This is distinct from pixelRatio.
I tested in Safari, Chrome and Firefox on macOS.