Skip to content

Commit a257336

Browse files
authored
Check for filterNextClick in evaluating isZoomingOrPanning (#924)
1 parent cf08c6a commit a257336

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/core.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,13 @@ export function isZoomedOrPanned(chart: Chart) {
274274
return false
275275
}
276276

277+
export function isZoomingOrPanningState(state: State) {
278+
return state.panning || state.dragging
279+
}
280+
277281
export function isZoomingOrPanning(chart: Chart) {
278282
const state = getState(chart)
279-
return state.panning || state.dragging
283+
// From the perspective of outside callers, zooming and panning are still
284+
// active if we haven't yet cleared the next click.
285+
return !!(isZoomingOrPanningState(state) || state.filterNextClick)
280286
}

src/plugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
getZoomedScaleBounds,
1212
isZoomedOrPanned,
1313
isZoomingOrPanning,
14+
isZoomingOrPanningState,
1415
zoomRect,
1516
} from './core'
1617
import { panFunctions, zoomFunctions, zoomRectFunctions } from './scale.types'
@@ -97,13 +98,13 @@ export default {
9798
chart: Chart,
9899
{ event }: { event: ChartEvent; replay: boolean; cancelable: true; inChartArea: boolean }
99100
): boolean | void {
100-
if (isZoomingOrPanning(chart)) {
101+
const state = getState(chart)
102+
if (isZoomingOrPanningState(state)) {
101103
// cancel any event handling while panning or dragging
102104
return false
103105
}
104106
// cancel the next click or mouseup after drag or pan
105107
if (event.type === 'click' || event.type === 'mouseup') {
106-
const state = getState(chart)
107108
if (state.filterNextClick) {
108109
state.filterNextClick = false
109110
return false

0 commit comments

Comments
 (0)