Skip to content

Commit 842a0b1

Browse files
authored
make animation/transition params optional (#5936)
They are not needed for most of the functions and should be marked as optional accordingly to make TypeScript users happy. Fixes sveltejs/language-tools#785
1 parent f00348c commit 842a0b1

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Throw a parser error for `class:` directives with an empty class name ([#5858](https://github.com/sveltejs/svelte/issues/5858))
66
* Fix type inference for derived stores ([#5935](https://github.com/sveltejs/svelte/pull/5935))
7+
* Make parameters of built-in animations and transitions optional ([#5936](https://github.com/sveltejs/svelte/pull/5936))
78

89
## 3.32.0
910

src/runtime/animate/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface FlipParams {
1616
easing?: (t: number) => number;
1717
}
1818

19-
export function flip(node: Element, animation: { from: DOMRect; to: DOMRect }, params: FlipParams): AnimationConfig {
19+
export function flip(node: Element, animation: { from: DOMRect; to: DOMRect }, params: FlipParams = {}): AnimationConfig {
2020
const style = getComputedStyle(node);
2121
const transform = style.transform === 'none' ? '' : style.transform;
2222
const scaleX = animation.from.width / node.clientWidth;

src/runtime/transition/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function blur(node: Element, {
2525
easing = cubicInOut,
2626
amount = 5,
2727
opacity = 0
28-
}: BlurParams): TransitionConfig {
28+
}: BlurParams = {}): TransitionConfig {
2929
const style = getComputedStyle(node);
3030
const target_opacity = +style.opacity;
3131
const f = style.filter === 'none' ? '' : style.filter;
@@ -50,7 +50,7 @@ export function fade(node: Element, {
5050
delay = 0,
5151
duration = 400,
5252
easing = linear
53-
}: FadeParams): TransitionConfig {
53+
}: FadeParams = {}): TransitionConfig {
5454
const o = +getComputedStyle(node).opacity;
5555

5656
return {
@@ -77,7 +77,7 @@ export function fly(node: Element, {
7777
x = 0,
7878
y = 0,
7979
opacity = 0
80-
}: FlyParams): TransitionConfig {
80+
}: FlyParams = {}): TransitionConfig {
8181
const style = getComputedStyle(node);
8282
const target_opacity = +style.opacity;
8383
const transform = style.transform === 'none' ? '' : style.transform;
@@ -104,7 +104,7 @@ export function slide(node: Element, {
104104
delay = 0,
105105
duration = 400,
106106
easing = cubicOut
107-
}: SlideParams): TransitionConfig {
107+
}: SlideParams = {}): TransitionConfig {
108108
const style = getComputedStyle(node);
109109
const opacity = +style.opacity;
110110
const height = parseFloat(style.height);
@@ -146,7 +146,7 @@ export function scale(node: Element, {
146146
easing = cubicOut,
147147
start = 0,
148148
opacity = 0
149-
}: ScaleParams): TransitionConfig {
149+
}: ScaleParams = {}): TransitionConfig {
150150
const style = getComputedStyle(node);
151151
const target_opacity = +style.opacity;
152152
const transform = style.transform === 'none' ? '' : style.transform;
@@ -177,7 +177,7 @@ export function draw(node: SVGElement & { getTotalLength(): number }, {
177177
speed,
178178
duration,
179179
easing = cubicInOut
180-
}: DrawParams): TransitionConfig {
180+
}: DrawParams = {}): TransitionConfig {
181181
const len = node.getTotalLength();
182182

183183
if (duration === undefined) {

0 commit comments

Comments
 (0)