-
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
Fixes shifted mouse events when CSS transform-scale applied #8017
Fixes shifted mouse events when CSS transform-scale applied #8017
Conversation
For some reason simulated mouse events are failing in |
db026a7
to
4d7fadc
Compare
I've updated to v1.0.0, but I still need someone to review these changes before looking into fixing the unit tests |
4d7fadc
to
fffc21b
Compare
@mourner not sure who to ask, but would be great if someone from the team could review this proposal. I might need some help with the tests, but I don't want to spent time on fixing them if this isn't something that's likely to make it in. |
Hi @adamcbrewer thanks for the PR and for being so patient. I think that this approach probably is not the right way to solve this issue. The I think that @jingsam was on the right track with their example in #7701 (comment) even if that particular implementation has some edge cases such as the ones you mentioned in that issue. The map shouldn't need to know what, if any, transforms have been applied to it. Using @peterqliu any thoughts on the best way forward on this issue? |
🤔 to take a step back, using transforms on the map verges on an antipattern to me, and is at best an edge case to support. Scaling is best done by resetting map dimensions directly. That said, I think this feature is limited in its upside, and in doing so introduces leaky abstractions (support for only certain transforms, on elements no higher in the DOM hierarchy) with the potential to add confusion and break expectations of intended behavior. I second @ryanhamley that the |
@peterqliu transform map does have its use cases. For example, If we create a dashboard that have maps, when presenting it on super big screen (I mean 4K X 2, or 1K X 6), it would cause two major problem:
On this case, we scale the map using transform, perfectly solve the problem.
|
Thanks for the reviews @peterqliu and @ryanhamley. I actually agree that it's an antipattern and also trying to maintain a set of css transforms is something to avoid. I really liked the I agree that handling transforms isn't the responsibility of GL JS, but in the comment above the Perhaps there's a way to kill all the events if the map has been scaled and the mouse/pointer has left the map area? Maybe supporting we find some way of supporting |
@jingsam tangent regarding big screens: you make a great point that big screens tend to also be farther away, where we can see less detail. This hints at the actual best practice: reducing screen resolution as they get bigger, as users can't see as finely anyway. We see this pattern in display resolutions between phones, tablets, and laptops. Handling this in the display settings is better than in CSS, because we can build the map once for all screens, without adding conditional logic to apply different transform scales for different screen sizes. |
@peterqliu I agree with you that adjusting screen resolution is a feasible way. However, sometimes we share this big screen with other applications. Adjusting its resolution maybe break other application appearance. Also, our dashboard need to deploy to different big screen, like 4k, 6k, 8k. Adjusting resolution maybe a little trivial. In our practice, we calculate the ratio between screen and dashboard size and scale the dashboard to autofit to the big screen. That's why we depend on transform feature a lot. In out fork of mapbox-gl, we use |
@peterqliu @jingsam Given this paradigm, is it even a big deal if |
Also, would being able to set the |
@ryanhamley I think we could use @ryanhamley thanks for your advice. Using |
@jingsam just to comment on what you said:
In fact Mapbox does allow panning the map outside the map bounds as long as the mouse/pointer is still held down. This is where I've noticed the issues with So really if we use
|
I think this PR should be closed and a new one created if |
agreed @adamcbrewer are you interested in working on a new PR for this? i'm not sure when someone on the GL JS team would get to it |
@ryanhamley I'd be happy to, but it would be good to get some thoughts on my previous comment: #8017 (comment)
|
This fixes 6079 and part of 7701 where mouse and touch events are incorrect when CSS transforms are applied to the map or any parent element wrapping it.
NOTE: The PR is a draft until someone can confirm this could be a sensible fix.