From 39024dce2e1ea6a6e89a6e7a05d0d81230899988 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Thu, 28 Jan 2021 11:36:16 +0100 Subject: [PATCH 1/2] Make animation/transition params optional They are not needed for most of the functions and should be marked as optional accordingly to make TypeScript users happy. Fixes https://github.com/sveltejs/language-tools/issues/785 --- src/runtime/animate/index.ts | 2 +- src/runtime/transition/index.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/runtime/animate/index.ts b/src/runtime/animate/index.ts index 82ec0d5a5fd4..ecfd9b29233d 100644 --- a/src/runtime/animate/index.ts +++ b/src/runtime/animate/index.ts @@ -16,7 +16,7 @@ interface FlipParams { easing?: (t: number) => number; } -export function flip(node: Element, animation: { from: DOMRect; to: DOMRect }, params: FlipParams): AnimationConfig { +export function flip(node: Element, animation: { from: DOMRect; to: DOMRect }, params: FlipParams = {}): AnimationConfig { const style = getComputedStyle(node); const transform = style.transform === 'none' ? '' : style.transform; const scaleX = animation.from.width / node.clientWidth; diff --git a/src/runtime/transition/index.ts b/src/runtime/transition/index.ts index 246f3b14fbe2..650688b6e0fd 100644 --- a/src/runtime/transition/index.ts +++ b/src/runtime/transition/index.ts @@ -25,7 +25,7 @@ export function blur(node: Element, { easing = cubicInOut, amount = 5, opacity = 0 -}: BlurParams): TransitionConfig { +}: BlurParams = {}): TransitionConfig { const style = getComputedStyle(node); const target_opacity = +style.opacity; const f = style.filter === 'none' ? '' : style.filter; @@ -50,7 +50,7 @@ export function fade(node: Element, { delay = 0, duration = 400, easing = linear -}: FadeParams): TransitionConfig { +}: FadeParams = {}): TransitionConfig { const o = +getComputedStyle(node).opacity; return { @@ -77,7 +77,7 @@ export function fly(node: Element, { x = 0, y = 0, opacity = 0 -}: FlyParams): TransitionConfig { +}: FlyParams = {}): TransitionConfig { const style = getComputedStyle(node); const target_opacity = +style.opacity; const transform = style.transform === 'none' ? '' : style.transform; @@ -104,7 +104,7 @@ export function slide(node: Element, { delay = 0, duration = 400, easing = cubicOut -}: SlideParams): TransitionConfig { +}: SlideParams = {}): TransitionConfig { const style = getComputedStyle(node); const opacity = +style.opacity; const height = parseFloat(style.height); @@ -146,7 +146,7 @@ export function scale(node: Element, { easing = cubicOut, start = 0, opacity = 0 -}: ScaleParams): TransitionConfig { +}: ScaleParams = {}): TransitionConfig { const style = getComputedStyle(node); const target_opacity = +style.opacity; const transform = style.transform === 'none' ? '' : style.transform; @@ -177,7 +177,7 @@ export function draw(node: SVGElement & { getTotalLength(): number }, { speed, duration, easing = cubicInOut -}: DrawParams): TransitionConfig { +}: DrawParams = {}): TransitionConfig { const len = node.getTotalLength(); if (duration === undefined) { From 4e07428a682496a277fa3a922750fa3f40291249 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 29 Jan 2021 10:37:56 -0500 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 928f76bfc98f..176ef0a1c2c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Throw a parser error for `class:` directives with an empty class name ([#5858](https://github.com/sveltejs/svelte/issues/5858)) * Fix type inference for derived stores ([#5935](https://github.com/sveltejs/svelte/pull/5935)) +* Make parameters of built-in animations and transitions optional ([#5936](https://github.com/sveltejs/svelte/pull/5936)) ## 3.32.0