From 9cc8f831a92b503bd8600a980fd852169cf6bdce Mon Sep 17 00:00:00 2001 From: liihuu Date: Wed, 5 Jun 2024 23:47:41 +0800 Subject: [PATCH] fix: fix x-axis scale error --- src/Event.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Event.ts b/src/Event.ts index b34ea3d41..1cb025fae 100644 --- a/src/Event.ts +++ b/src/Event.ts @@ -18,7 +18,6 @@ import type Coordinate from './common/Coordinate' import { UpdateLevel } from './common/Updater' import type Crosshair from './common/Crosshair' import { requestAnimationFrame, cancelAnimationFrame } from './common/utils/compatible' -import { isNumber } from './common/utils/typeChecks' import { type AxisRange } from './component/Axis' import type YAxis from './component/YAxis' @@ -275,11 +274,13 @@ export default class Event implements EventHandler { const consumed = widget.dispatchEvent('pressedMouseMoveEvent', event) if (!consumed) { const xAxis = (pane as DrawPane).getAxisComponent() - if ((xAxis?.getScrollZoomEnabled() ?? true) && isNumber( event.pageX)) { + if ((xAxis?.getScrollZoomEnabled() ?? true)) { const scale = this._xAxisStartScaleDistance / event.pageX - const zoomScale = (scale - this._xAxisScale) * 10 - this._xAxisScale = scale - this._chart.getChartStore().getTimeScaleStore().zoom(zoomScale, this._xAxisStartScaleCoordinate ?? undefined) + if (Number.isFinite(scale)) { + const zoomScale = (scale - this._xAxisScale) * 10 + this._xAxisScale = scale + this._chart.getChartStore().getTimeScaleStore().zoom(zoomScale, this._xAxisStartScaleCoordinate ?? undefined) + } } } else { this._chart.updatePane(UpdateLevel.Overlay)