Merge pull request #2381 from sveltejs/gh-2380

add scale transition
pull/2373/head
Rich Harris 6 years ago committed by GitHub
commit cf095c4723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -409,7 +409,7 @@ As with `tweened` stores, `set` and `update` return a Promise that resolves if t
TODO
* fade, fly, slide, draw
* fade, fly, slide, scale, draw
* crossfade...
### svelte/animation

@ -66,6 +66,32 @@ export function slide(node, {
};
}
export function scale(node, {
delay = 0,
duration = 400,
easing = cubicOut,
start = 0,
opacity = 0
}) {
const sd = 1 - start;
const od = 1 - opacity;
const transform = (
node.style.transform ||
getComputedStyle(node).transform
).replace('none', '');
return {
delay,
duration,
easing,
css: (t, u) => `
transform: ${transform} scale(${1 - (sd * u)});
opacity: ${1 - (od * u)}
`
};
}
export function draw(node, {
delay = 0,
duration = 800,

Loading…
Cancel
Save