-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Viewport-level interaction events #1825
Comments
👍 thats on my todo |
Hey guys! I would like to help you out with this. The idea here is to avoid computation of events outside the viewport? |
No, the idea is that right now you can't handle interaction events across the entire viewport. In v2 you could listen to events on the stage and it would return all events across the entire viewport regardless of if something was there to be interacted with or not. Currently in v3 that is impossible. |
Related to #2071 |
👍 |
Is this still the case with version 4? |
Yes, its still the case. Right now the best way is to create a rectangle and update it on resize stage.hitArea = new PIXI.Rectangle(0, 0, renderer.width/renderer.resolution, renderer.height/renderer.resolution); |
Global interaction events are available on the InteractionManager via #2658. This is in 4.0.0-rc3 |
Is there any information on how this works? I seem to have got a basic implementation working by adding .on('mousedown'.. to a stage but it only fires when mousing down on a graphic inside the stage when I want it to fire anywhere on the stage. Is this because a stage has no real graphical representation and thus if you're not click on one of the stages/containers objects then you're not really clicking on the stage and I should do what ivanpopelyshev is suggesting? EDIT: Scratch that, the correct solution is to create a new interaction manager passing in the renderer, like so:
|
@SamStonehouse: Does this help? let backdrop = new PIXI.Container();
backdrop.interactive = true;
backdrop.containsPoint = () => true;
// add backdrop to scene graph... |
Having |
@SamStonehouse something like this: var renderer = new PIXI.autoDetectRenderer();
renderer.plugins.interaction.on('mousedown', function(){
console.log("Mouse is down");
}); |
Also note that #2658 only emits a subset of events otherwise provided by |
Interesting @bigtimebuddy that works too, I don't know which the correct way would be.
|
@akbr I was under the assumption left/right/middle would be handled by the same mousedown event, the middle button seems to be |
@SamStonehouse While both work, I would recommend |
@bigtimebuddy Great thank you I've also solved the right click issue, it is indeed another mouse event (which I would say is intuitive). Thanks all |
Hi, this is working pretty fantastically for implementing panning/zooming functionality with Pixi v4. However, Alternatively, is there a way to implement a drag-and-pan functionality without using the EDIT: I was able to get my former method working, it turns out that I was applying the wrong offset to my newly created hitArea Rectangles, but I'm still curious to know about how to intercept events that would hit |
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. |
Right now the only way to get viewport-level interaction events is to create a dummy DO and force its width to the viewport size.
The interaction manager should handle this better.
The text was updated successfully, but these errors were encountered: