import { assign, noop } from './utils.js'; export function linear ( t ) { return t; } export function generateKeyframes ( a, b, delta, duration, ease, fn, node, style ) { var id = '__svelte' + ~~( Math.random() * 1e9 ); // TODO make this more robust var keyframes = '@keyframes ' + id + '{\n'; for ( var p = 0; p <= 1; p += 16.666 / duration ) { var t = a + delta * ease( p ); keyframes += ( p * 100 ) + '%{' + fn( t ) + '}\n'; } keyframes += '100% {' + fn( b ) + '}\n}'; style.textContent += keyframes; document.head.appendChild( style ); node.style.animation = node.style.animation.split( ',' ) .filter( function ( anim ) { // when introing, discard old animations if there are any return anim && ( delta < 0 || !/__svelte/.test( anim ) ); }) .concat( id + ' ' + duration + 'ms linear 1 forwards' ) .join( ', ' ); } export function wrapTransition ( node, fn, params, intro, outgroup ) { var obj = fn( node, params, intro ); var duration = obj.duration || 300; var ease = obj.easing || linear; // TODO share