Added mouse wheel event to submap scatter.
This commit is contained in:
parent
f3fed535d8
commit
096e374997
@ -272,15 +272,49 @@ export class SubmapScatter extends DisplayObjectScatter {
|
|||||||
})
|
})
|
||||||
|
|
||||||
super(displayObject, renderer, opts)
|
super(displayObject, renderer, opts)
|
||||||
|
|
||||||
console.log('onResize', opts.onResize)
|
|
||||||
this.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) {
|
gesture(interaction) {
|
||||||
super.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() {
|
get width() {
|
||||||
|
Loading…
Reference in New Issue
Block a user