Skip to content

Commit

Permalink
fix(Spline): Improve initial tweened transition
Browse files Browse the repository at this point in the history
  • Loading branch information
techniq committed Nov 5, 2024
1 parent d94a89b commit ddddb7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fifty-spiders-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'layerchart': patch
---

fix(Spline): Improve initial `tweened` transition
9 changes: 8 additions & 1 deletion packages/layerchart/src/lib/components/Spline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,17 @@
$: xOffset = isScaleBand($xScale) ? $xScale.bandwidth() / 2 : 0;
$: yOffset = isScaleBand($yScale) ? $yScale.bandwidth() / 2 : 0;
/** Provide initial `0` horizontal baseline and initially hide/untrack scale changes so not reactive (only set on initial mount) */
function defaultPathData() {
const [xRangeMin, xRangeMax] = $xScale.range();
const yRangeZero = $yScale(0);
return `M${xRangeMin},${yRangeZero} L${xRangeMax},${yRangeZero}`;
}
let d: string | null = '';
// @ts-expect-error
$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
$: tweened_d = motionStore('', { tweened: tweenedOptions });
$: tweened_d = motionStore(defaultPathData(), { tweened: tweenedOptions });
$: {
const path = $radial
? lineRadial()
Expand Down

0 comments on commit ddddb7e

Please sign in to comment.