Skip to content

Commit 078c5bc

Browse files
on Pan return actual pan delta instead of desired delta.
1 parent d38ee88 commit 078c5bc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/core.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,21 @@ export function pan(chart: Chart, delta: PanAmount, enabledScales?: Scale[], tra
224224
const yEnabled = y !== 0
225225

226226
const scales = enabledScales || Object.values(chart.scales)
227+
const actualDelta = { x: 0, y: 0 }
227228

228229
for (const scale of scales) {
229230
if (scale.isHorizontal() && xEnabled) {
231+
actualDelta.x = x
230232
panScale(scale, x, limits, state)
231233
} else if (!scale.isHorizontal() && yEnabled) {
234+
actualDelta.y = y
232235
panScale(scale, y, limits, state)
233236
}
234237
}
235238

236239
chart.update(transition)
237240

238-
onPan?.({ chart, trigger, delta })
241+
onPan?.({ chart, trigger, delta: actualDelta })
239242
}
240243

241244
export function getInitialScaleBounds(chart: Chart) {

0 commit comments

Comments
 (0)