question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interactions fail in shadow DOM of web component

See original GitHub issue

Expected 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

  1. Clicks on interactive display objects don’t work.
  2. Clicking an interactive stage doesn’t even trigger pointerdown events.

Possible Solution

  1. 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.
  2. 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

  1. Open fiddle at https://jsfiddle.net/soletan/r9kLstd8/40/
  2. Click on red box and observe event handlers logging in on-screen console (or failing to do so).
  3. Click on black stage and observe console logging again (though there is no logging).

Environment

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
stale[bot]commented, Jun 2, 2021

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.

1reaction
soletancommented, Jan 18, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found