pull/1947/head
Richard Harris 6 years ago
parent 16fea037f3
commit d5e41a8a2e

@ -28,7 +28,7 @@ export function animate(node, from, fn, params) {
if (css) { if (css) {
if (delay) node.style.cssText = cssText; if (delay) node.style.cssText = cssText;
name = create_rule({ a: 0, b: 1, delta: 1, duration }, easing, css); name = create_rule({ a: 0, b: 1, d: 1, duration }, easing, css);
node.style.animation = (node.style.animation || '') node.style.animation = (node.style.animation || '')
.split(', ') .split(', ')

@ -13,12 +13,12 @@ function hash(str) {
return hash >>> 0; return hash >>> 0;
} }
export function create_rule({ a, b, delta, duration }, ease, fn) { export function create_rule({ a, b, d, duration }, ease, fn) {
const step = 16.666 / duration; const step = 16.666 / duration;
let keyframes = '{\n'; let keyframes = '{\n';
for (let p = 0; p <= 1; p += step) { for (let p = 0; p <= 1; p += step) {
const t = a + delta * ease(p); const t = a + d * ease(p);
keyframes += p * 100 + `%{${fn(t, 1 - t)}}\n`; keyframes += p * 100 + `%{${fn(t, 1 - t)}}\n`;
} }

Loading…
Cancel
Save