Skip to content

Commit ac3c7bb

Browse files
committed
feat: adds rotation property
1 parent b3437e6 commit ac3c7bb

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

packages/svelte/src/animate/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function flip(node, { from, to }, params = {}) {
2121

2222
var dx = (from.left + dsx * ox - (to.left + ox)) / zoom;
2323
var dy = (from.top + dsy * oy - (to.top + oy)) / zoom;
24-
var { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing = cubicOut } = params;
24+
var { delay = 0, duration = (d) => Math.sqrt(d) * 120, easing = cubicOut, rotation = 0 } = params;
2525

2626
return {
2727
delay,
@@ -30,9 +30,10 @@ export function flip(node, { from, to }, params = {}) {
3030
css: (t, u) => {
3131
var x = u * dx;
3232
var y = u * dy;
33+
var r = u * rotation;
3334
var sx = t + u * dsx;
3435
var sy = t + u * dsy;
35-
return `transform: ${transform} scale(${sx}, ${sy}) translate(${x}px, ${y}px);`;
36+
return `transform: ${transform} scale(${sx}, ${sy}) translate(${x}px, ${y}px) rotate(${r}deg);`;
3637
}
3738
};
3839
}

packages/svelte/src/animate/public.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface FlipParams {
1111
delay?: number;
1212
duration?: number | ((len: number) => number);
1313
easing?: (t: number) => number;
14+
rotation?: number;
1415
}
1516

1617
export * from './index.js';

packages/svelte/types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ declare module 'svelte/animate' {
581581
delay?: number;
582582
duration?: number | ((len: number) => number);
583583
easing?: (t: number) => number;
584+
rotation?: number;
584585
}
585586
/**
586587
* The flip function calculates the start and end position of an element and animates between them, translating the x and y values.

0 commit comments

Comments
 (0)