Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make animation/transition params optional #5936

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/animate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/runtime/transition/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down