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.

Graphics.hitArea not triggering interaction when mask attached

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
staff0rdcommented, Jan 18, 2017

@ricklamers actually it does look like a bug here. I tried setting hitArea on the graphics object and the handlers are not triggered. Currently the only work around is to use beginFill.

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.

0reactions
lock[bot]commented, Feb 24, 2019

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.

Read more comments on GitHub >

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

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