Skip to content

Commit

Permalink
fix: fix x-axis scale error
Browse files Browse the repository at this point in the history
  • Loading branch information
liihuu committed Jun 5, 2024
1 parent 67ee63c commit 9cc8f83
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -275,11 +274,13 @@ export default class Event implements EventHandler {
const consumed = widget.dispatchEvent('pressedMouseMoveEvent', event)
if (!consumed) {
const xAxis = (pane as DrawPane<XAxis>).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)
Expand Down

0 comments on commit 9cc8f83

Please sign in to comment.