Skip to content

Commit 060f739

Browse files
committed
fix: animation before no updated
1 parent 89ce44b commit 060f739

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/components/Chart.svelte

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,29 @@
282282
283283
function setViewport(x1: number, y1: number, x2: number, y2: number, animated = false): void {
284284
if (animated) {
285-
animation.set({
286-
xMin: x1,
287-
yMin: y1,
288-
xMax: x2,
289-
yMax: y2,
290-
});
285+
// update to current value
286+
animation.set(
287+
{
288+
xMin,
289+
yMin,
290+
xMax,
291+
yMax,
292+
},
293+
{
294+
duration: 0,
295+
},
296+
);
297+
animation.set(
298+
{
299+
xMin: x1,
300+
yMin: y1,
301+
xMax: x2,
302+
yMax: y2,
303+
},
304+
{
305+
duration: 750,
306+
},
307+
);
291308
} else {
292309
xMin = x1;
293310
xMax = x2;

0 commit comments

Comments
 (0)