Skip to content

Commit a99d667

Browse files
committed
Handle scales removed while panning
To fix this, instead of tracking the actual Scale objects, I'm tracking scale IDs. Fixes #929
1 parent a257336 commit a99d667

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/hammer.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ function handlePan(chart: Chart, state: State, e: HammerInput) {
9595
const delta = state.delta
9696
if (delta) {
9797
state.panning = true
98-
pan(chart, { x: e.deltaX - delta.x, y: e.deltaY - delta.y }, state.panScales)
98+
pan(
99+
chart,
100+
{ x: e.deltaX - delta.x, y: e.deltaY - delta.y },
101+
state.panScales && state.panScales.map((i) => chart.scales[i]).filter(Boolean)
102+
)
99103
state.delta = { x: e.deltaX, y: e.deltaY }
100104
}
101105
}
@@ -115,7 +119,7 @@ function startPan(chart: Chart, state: State, event: HammerInput) {
115119
return onPanRejected?.({ chart, event })
116120
}
117121

118-
state.panScales = getEnabledScalesByPoint(state.options.pan, point, chart)
122+
state.panScales = getEnabledScalesByPoint(state.options.pan, point, chart).map((i) => i.id)
119123
state.delta = { x: 0, y: 0 }
120124
handlePan(chart, state, event)
121125
}

src/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface State {
3636
filterNextClick?: boolean
3737
scale?: number | null
3838
delta?: Point | null
39-
panScales?: Scale[]
39+
panScales?: string[]
4040
}
4141

4242
const chartStates = new WeakMap<Chart, State>()

0 commit comments

Comments
 (0)