Skip to content
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

Brushing uses wrong mouse coordinates if perspective transformations are applied #85

Open
s9ferech opened this issue Apr 16, 2021 · 3 comments

Comments

@s9ferech
Copy link

If I zoom in on a visualization through CSS perspective transformations then brushing on that visualizations will behave weird because the wrong mouse coordinates will be used. I created a small example to demonstrate this. When brushing over the circle, the selection does not follow the cursor.

@Fil
Copy link
Member

Fil commented Apr 19, 2021

Confirmed in d3v6. Do you have an idea to solve this?

I think the issue is in d3.pointer, not specifically d3.brush.

It's fun to see that it doesn't happen with 2D transforms, like transform: rotate(45deg), where the brush seems to correctly follow the mouse.

@mbostock
Copy link
Member

Related d3/d3-selection#67 d3/d3-selection#68 d3/d3-selection#72 d3/d3-selection#81

There’s a long history of browsers not implementing getScreenCTM correctly, and generally speaking I don’t think D3 should attempt to workaround browser bugs or quirks: D3 is not a compatibility layer.

@s9ferech
Copy link
Author

The properties MouseEvent.offsetX and MouseEvent.offsetY seem to provide the right coordinates in Chrome and Firefox. I suppose they could be used to fix this without much trouble. But their specification is currently still experimental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants