diff --git a/lib/pixi/maps/scatter.js b/lib/pixi/maps/scatter.js index 57fe61a..accd92c 100644 --- a/lib/pixi/maps/scatter.js +++ b/lib/pixi/maps/scatter.js @@ -272,15 +272,49 @@ export class SubmapScatter extends DisplayObjectScatter { }) super(displayObject, renderer, opts) - - console.log('onResize', opts.onResize) this.onResize = opts.onResize } + + /** + * Adds mouse wheel resizing to the submap. + * + * @param {MouseEvent} event - Event containing the mouse data. + * @memberof SubmapScatter + */ + onMouseWheel(event) { + super.onMouseWheel(event) + + if (this.onResize) { + const zoomFactor = 0.001 + let zoom = 1 + zoomFactor * event.deltaY + + let anchor = { + x: event.offsetX, + y: event.offsetY + } + + this.onResize(anchor, zoom) + } + } + + + /** + * Overwrites the gesture to get access to the interaction pivot and scaling information. + * This calls the resize method to resize the submap. + * + * @private + * @param {interaction} interaction - Interaction element containing various informations about the touch interaction. + * @memberof SubmapScatter + */ gesture(interaction) { super.gesture(interaction) - if (this.onResize) this.onResize(interaction) + if (this.onResize) { + let delta = interaction.delta() + + this.onResize(delta.about, delta.zoom) + } } get width() {