Skip to content

Commit

Permalink
fix: fix zoomAtCoordinate, zoomAtDataIndex and zoomAtTimestamp
Browse files Browse the repository at this point in the history
…scale error
  • Loading branch information
liihuu committed Jun 4, 2024
1 parent 7d1464b commit 08569c9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -908,11 +908,14 @@ export default class ChartImp implements Chart {
const scaleDataSpace = barSpace * scale
const difSpace = scaleDataSpace - barSpace
const startTime = new Date().getTime()
let preScale = 0
const animation: (() => void) = () => {
const progress = (new Date().getTime() - startTime) / duration
const finished = progress >= 1
const progressDataSpace = finished ? difSpace : difSpace * progress
timeScaleStore.zoom(progressDataSpace / barSpace, coordinate)
const scale = progressDataSpace / barSpace
timeScaleStore.zoom(scale - preScale, coordinate)
preScale = scale
if (!finished) {
requestAnimationFrame(animation)
}
Expand Down

0 comments on commit 08569c9

Please sign in to comment.