Skip to content

Commit ea1ee46

Browse files
onZoom: Return focalPoint to correctly sync zoom and remove actualAmount which was meant to indicate which scale was actually zoomed in favor of concise code.
1 parent ee3e78b commit ea1ee46

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/core.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,18 @@ export function zoom(chart: Chart, amount: ZoomAmount, transition: UpdateMode =
7878
const xEnabled = x !== 1
7979
const yEnabled = y !== 1
8080
const enabledScales = getEnabledScalesByPoint(zoomOptions, focalPoint, chart)
81-
const actualAmount = { x: 1, y: 1 }
8281

8382
for (const scale of enabledScales) {
8483
if (scale.isHorizontal() && xEnabled) {
85-
actualAmount.x = x
8684
doZoom(scale, x, focalPoint, limits)
8785
} else if (!scale.isHorizontal() && yEnabled) {
88-
actualAmount.y = y
8986
doZoom(scale, y, focalPoint, limits)
9087
}
9188
}
9289

9390
chart.update(transition)
9491

95-
zoomOptions?.onZoom?.({ chart, trigger, amount: actualAmount })
92+
zoomOptions?.onZoom?.({ chart, trigger, amount: { x, y, focalPoint } })
9693
}
9794

9895
export function zoomRect(

src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export interface ZoomOptions {
121121
/**
122122
* Function called while the user is zooming
123123
*/
124-
onZoom?: (context: { chart: Chart; trigger: ZoomTrigger; amount?: { x: number, y: number } }) => void
124+
onZoom?: (context: { chart: Chart; trigger: ZoomTrigger; amount?: { x: number, y: number } & { focalPoint: Point } }) => void
125125

126126
/**
127127
* Function called once zooming is completed

0 commit comments

Comments
 (0)