Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,13 @@ export function isZoomedOrPanned(chart: Chart) {
return false
}

export function isZoomingOrPanningState(state: State) {
return state.panning || state.dragging
}

export function isZoomingOrPanning(chart: Chart) {
const state = getState(chart)
return state.panning || state.dragging
// From the perspective of outside callers, zooming and panning are still
// active if we haven't yet cleared the next click.
return !!(isZoomingOrPanningState(state) || state.filterNextClick)
}
5 changes: 3 additions & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getZoomedScaleBounds,
isZoomedOrPanned,
isZoomingOrPanning,
isZoomingOrPanningState,
zoomRect,
} from './core'
import { panFunctions, zoomFunctions, zoomRectFunctions } from './scale.types'
Expand Down Expand Up @@ -97,13 +98,13 @@ export default {
chart: Chart,
{ event }: { event: ChartEvent; replay: boolean; cancelable: true; inChartArea: boolean }
): boolean | void {
if (isZoomingOrPanning(chart)) {
const state = getState(chart)
if (isZoomingOrPanningState(state)) {
// cancel any event handling while panning or dragging
return false
}
// cancel the next click or mouseup after drag or pan
if (event.type === 'click' || event.type === 'mouseup') {
const state = getState(chart)
if (state.filterNextClick) {
state.filterNextClick = false
return false
Expand Down
Loading