Graphics.hitArea not triggering interaction when mask attached
See original GitHub issueI think I found a bug in pixi.js.
If I add a mask like this:
this.container = new PIXI.Container();
var mask = new PIXI.Graphics();
//mask.beginFill(0x000000); <-- note I'm not calling this line
mask.drawRect(0,0,500,500);
this.addChild(mask);
this.container.mask = mask;
When I run this, I do see that the mask is clipping the content but the interaction is not working, only after I added beginFill(0x000000) it started clipping and allowing interaction.
Maybe it’s just a mistake on my side, but I spent almost an hour figuring this out. I initially thought I had to set filterArea (which according to the comments in the source is also responsible for interaction clipping in v4, which was hard to find in the docs) in order to get interaction to work.
Maybe this is not so much of a bug as a documentation issue, I just didn’t know how to get masking + interaction working. Turns out, I just needed to call beginFill(0x000000) on the masking object.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7
Top Results From Across the Web
Graphics.hitArea not triggering interaction when mask attached
I think I found a bug in pixi.js. If I add a mask like this: this.container = new PIXI.Container(); var mask = new...
Read more >PIXI.Container - PixiJS API Documentation
It is the base class of all display objects that act as a container for other objects, including Graphics and Sprite.
Read more >PIXI.DisplayObject
DisplayObject's interactive property must be set to true to fire event. This event is specific to the Federated Events API. It does not...
Read more >PIXI.animate.MovieClip - PixiJS API Documentation
Graphics or a PIXI.Sprite object. This allows for much faster masking in canvas as it utilises shape clipping. To remove a mask, set...
Read more >Masking Emotions: Face Masks Impair How We Read Emotions
Emotion Inference Without Masks. Identification of emotions and, particularly, of facial movements is fundamental for our ability to interact with others and ...
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 Free
Top 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
@ricklamers actually it does look like a bug here. I tried setting
hitArea
on thegraphics
object and the handlers are not triggered. Currently the only work around is to usebeginFill
.I’ll write some tests to help determine where the issue is - won’t be able to do this until around 24 hours from this post however. For now i’ll mark this as a bug.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.