From 6a773322a12e814659b1d94364b95f7e73d615fd Mon Sep 17 00:00:00 2001 From: Korbinian Eckstein Date: Wed, 8 Nov 2023 14:43:55 +1000 Subject: [PATCH] generalize zoom synchronization; pan2Dxyzmm for middle and right mouse button drags are synchronized --- niivue/events.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/niivue/events.ts b/niivue/events.ts index f447b61..e687051 100644 --- a/niivue/events.ts +++ b/niivue/events.ts @@ -225,16 +225,15 @@ class ExtendedNiivue extends Niivue { constructor(opts: any) { super(opts) } - dragForSlicer3D(startXYendXY: number[]) { - this.canvas.focus() - super.dragForSlicer3D(startXYendXY) - this.otherNV.forEach((nv: Niivue) => { - nv.uiData.pan2Dxyzmm[0] = this.uiData.pan2Dxyzmm[0] - nv.uiData.pan2Dxyzmm[1] = this.uiData.pan2Dxyzmm[1] - nv.uiData.pan2Dxyzmm[2] = this.uiData.pan2Dxyzmm[2] - nv.uiData.pan2Dxyzmm[3] = this.uiData.pan2Dxyzmm[3] - nv.drawScene() - }) + mouseMoveListener(e: MouseEvent) { + super.mouseMoveListener(e) + if (this.uiData.mouseButtonRightDown || this.uiData.mouseButtonCenterDown) { + this.canvas.focus() + this.otherNV.forEach((nv: Niivue) => { + nv.uiData.pan2Dxyzmm = this.uiData.pan2Dxyzmm.slice() + nv.drawScene() + }) + } } }