Open krnbatta opened 4 years ago
viewport.wheel()
will let you zoom with the mouse wheel at the mouse location. See docs here: https://davidfig.github.io/pixi-viewport/jsdoc/Viewport.html#wheel
It is actually broken if you don't render your canvas over whole body and do not supply an InteractionManager from PIXI app. Solution 1:
const viewport = new Viewport({
divWheel: document.getElementById('my-canvas-wrapper'),
interaction: app.renderer.plugins.interaction, // app is PIXI.Application
...
});
Solution 2:
provide only divWheel
and wait if https://github.com/davidfig/pixi-viewport/pull/226 gets merged :)
Why do you prefer solution #2?
I didn't mean I prefer it. I just noticed (and prepared a PR with fix) yesterday that the builtin handler is broken under these circumstances (we previously overlooked the insertion of PIXI interaction manager in our codebase). I actually used the solution 1 in my codebase too because I think it will lead to more consistent behavior with PIXI app itself, however the bug is still worth fixing.
Is there any way to get zooming focused at the mouse position. For now, it is difficult to understand the proper pattern to it. I want to zoom like how Google Maps work. Is this what originally happens or supposed to happen and I am doing something wrong? Or is there any particular flag that needs to be turned on or off?