davidfig / pixi-viewport

A highly configurable viewport/2D camera designed to work with pixi.js
https://davidfig.github.io/pixi-viewport/
MIT License
1.04k stars 174 forks source link

How to check if the container inside pixi-viewport contains a point returned by the "on wheel" event? #465

Open devexus opened 11 months ago

devexus commented 11 months ago

When I use "zoomed" listener it returns only "type" and "viewport". How can I get information about pointer position? image

blnvdanil commented 11 months ago

There is no simple way to do that, since viewport just firest the event that way. You can copy the source code of a wheel plugin and add custom parameters in every place where the event is fired.

Why would you need to do that at all?

devexus commented 11 months ago

I used 2 event listeners one wheel event, and zoomed event. The first one returns mouse position, then I story it in a variable and I have a access to that variable in zoomed event.

I want to do something like zoom-in image which is in lower resolution, then when scale is reached I want to change view with selected image in higher resolution.

blnvdanil commented 11 months ago

But why would you need to check if the pointer is inside of an image? Why cant you just check if the image is still visible in viewport? You just need to check if viewport's current rectangle intersects image's rectangle