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

Pointer events attach to canvas, not item #3

Open
rossb opened this issue Jun 26, 2024 · 2 comments
Open

Pointer events attach to canvas, not item #3

rossb opened this issue Jun 26, 2024 · 2 comments

Comments

@rossb
Copy link

rossb commented Jun 26, 2024

Hi, this is an amazing library, thanks for creating and sharing it.

As a feature request, could an option be added so events attach to the item being transformed, rather than their containing canvas element?

The use case I have in mind is displaying multiple items in the same canvas where they can be composed next to each other, and being able to zoom and move each based on events over the bounds of each item.

I think this use case may require a second feature request actually, though I've not been able to confirm this in testing — that multiple items could share the same canvas element (so all items can receive pointer events and not be blocked by the frontmost canvas).

Thanks and keep up the great work! This performs amazingly in the browser.

@MauriceConrad
Copy link
Owner

MauriceConrad commented Jul 1, 2024

I think it would be not that much pain to implement it. But I think it would mess up the core logic if we would implement it on the same level as the existing logic. If I understood the requirement correctly, we could just make an option that makes the entire component pointer-events: none except a given element within the canvas or the matrix slots. Now, just laying different components on top of each other would lead to the intended behavior, or am I missing something?

@rossb
Copy link
Author

rossb commented Jul 3, 2024

I think pointer-events: none will work for this case like you say, actually! I've never had the need to test this before, but can see reverting pointer-events on a descendent does re-enable events, while keeping the parent canvas events disabled (my assumption was it couldn't be excluded from parent).

Thanks for the suggestion, I'm going to try this out. The case I'm describing currently uses Panzoom, and I'd love to switch to zoompinch for the amazing mathematically correct pinch projection. The only potential glitch might be if pointer events are momentarily seen as outside the child during pinch, but TBC!

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

No branches or pull requests

2 participants