Interactions fail in shadow DOM of web component
See original GitHub issueExpected Behavior
I’d love to use PIXI.js in context of a web component (made with stenciljs) for rendering an interactive map combining PIXI and leaflet. Markers should be clickable and draggable, thus need to have all interaction events working properly. For ease of implementation there should be a sole covering handler per event on stage or some other container for capturing and handling clicks etc.
Current Behavior
- Clicks on interactive display objects don’t work.
- Clicking an interactive stage doesn’t even trigger pointerdown events.
Possible Solution
- Click on display object: following some investigating I conclude that this is due to *up-event’s target referring to the wrapping component (host element) rather than PIXI’s canvas (a.k.a. interactionDOMElement) … thus it assumes *up event having occurred outside of its view and thus doesn’t click, but considers interaction sort of cancelled.
- Click on stage isn’t recognized at all: haven’t investigated this one, but I assume this is kind of intentional, though stage is a PIXI.Container which is a display object as well. (isn’t it?)
Steps to Reproduce
- Open fiddle at https://jsfiddle.net/soletan/r9kLstd8/40/
- Click on red box and observe event handlers logging in on-screen console (or failing to do so).
- Click on black stage and observe console logging again (though there is no logging).
Environment
pixi.js
version: 6.0.0-rc.2- Browser & Version: Firefox 84
- OS & Version: Windows 10
- Running Example: https://jsfiddle.net/soletan/r9kLstd8/40/
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Interactions fail in shadow DOM of web component #7165
I'd love to use PIXI.js in context of a web component (made with stenciljs) for rendering an interactive map combining PIXI and leaflet....
Read more >Track Interactions In The Shadow DOM Using Google Tag ...
The shadow DOM is a way to add HTML structures to the web page so that they remain isolated from the rest of...
Read more >Shadow DOM v1 - Self-Contained Web Components
Isolated DOM: A component's DOM is self-contained (e.g. document. querySelector() won't return nodes in the component's shadow DOM). Scoped CSS ...
Read more >Relic Solution: Interacting with elements in a Shadow DOM
I've put together an example below that demonstrates how to interact with a Shadow DOM element, using Javascript and $browser.
Read more >Chapter 8. The Shadow DOM - Web Components in Action
This chapter covers. Component and class encapsulation; How the Shadow DOM protects your component's DOM; The open and closed Shadow DOM; Shadow DOM...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Regarding the hitarea: I see.
Regarding component support: using web components is very handy nowadays. In the existing project I had to switch that component to use a fallback method instead of native shadow DOM. As far as I can tell it’s having remarkable negative impact on its rendering performance. When using the component events are basically getting through and I assume all it takes is a different information to be evaluated to discover whether pointer has actually left the listening part of PIXI’s tree.