Event capture not supported, fine. But capture not even hackable outside of pixi, NOT fine!
See original GitHub issueHi, I’ve been stumbling on this problem a couple of times now so I think it’s in place to get this clarified once and for all.
I know the capture phase is not supported by pixijs. That’s OK for now. However, when I try to catch events this way I would expect it to work properly (pixiCanvas is my renderer’s view element):
pixiCanvas.addEventListener('mousedown' , this.onPointerDownCapture, true);
this.on("mousedown" , this.onPointerDown, this);
When I do this, onPointerDown is called BEFORE onPointerDownCapture, which is extremely annoying because it means I cannot hack around to get any type of capture working as long as pixi is loaded onto the page. And I really have to capture it before in order to have a proper and simple design for my event handling code…
If I recall my last investigation correctly I think that pixi attaches its listeners to the window, the topmost possible object, which I think is the reason why it is so hard to hack around it. If an event is captured there, the only option to have a chance capturing it before pixi is to make a really ugly hack to get my handler added to window before pixi is even loaded. Maybe possible, but that would be really ugly and require a huge inline comment to explain why that has to be done.
Maybe I have missed something fundamental. If so, please let me know. Otherwise my suggestion is that we ensure that pixi never attaches any listeners to elements above its view in the page element hierarchy.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top GitHub Comments
I managed to solve my problem another way, involving attachment of data to the bubbling events. However, still, for the future I think the attachement of capturing event handlers to window and window.document should be revised and changed if possible. I suppose it should be possible to attach them to the renderer view element instead, but maybe there is some reason why it had to be done this way. If so, an explanation here would be great.
Thanks, Ivan, for the fast reply, the code pointer, and for all your great posts that have helped me a lot so far!
I’ll try to avoid hacking pixi as much as I can (for a rock solid upgrade process), but I’ll let you know if I fall back to replace addEvents!