function animate(el, effect, timing) {
  if (!el) return of(new CustomEvent('finish'));

  return Observable.create((observer) => {
    const anim = el.animate(effect, timing);

    anim.addEventListener('finish', (e) => {
      observer.next(e);
      requestAnimationFrame(() => {
        requestAnimationFrame(() => observer.complete());
      });
    });

    return () => {
      if (anim.playState !== 'finished') anim.cancel();
    };
  });
}
/**
 * An observable wrapper for the WebAnimations API.
 * Will return an observable that emits once when the animation finishes.
 * @param {HTMLElement|null} el
 * @param {AnimationKeyFrame | AnimationKeyFrame[] | null} effect
 * @param {number|AnimationEffectTiming} timing
 * @returns {Observable<Event>}
 */
An observable wrapper for the WebAnimations API.
Will return an observable that emits once when the animation finishes.
@param {HTMLElement|null} el
@param {AnimationKeyFrame | AnimationKeyFrame[] | null} effect
@param {number|AnimationEffectTiming} timing
@returns {Observable}
An observable wrapper for the WebAnimations API . Will return an observable that emits once when the animation finishes . @param { HTMLElement|null } el @param { AnimationKeyFrame | AnimationKeyFrame [] | null } effect @param { number|AnimationEffectTiming } timing @returns { Observable }
function animate(el, effect, timing) {
  if (!el) return of(new CustomEvent('finish'));
  return Observable.create((observer) => {
    const anim = el.animate(effect, timing);
    anim.addEventListener('finish', (e) => {
      observer.next(e);
      requestAnimationFrame(() => {
        requestAnimationFrame(() => observer.complete());
      });
    });
    return () => {
      if (anim.playState !== 'finished') anim.cancel();
    };
  });
}
function animate ( el , effect , timing ) { if ( ! el ) return of ( new CustomEvent ( 'finish' ) ) ; return Observable . create ( ( observer ) => { const anim = el . animate ( effect , timing ) ; anim . addEventListener ( 'finish' , ( e ) => { observer . next ( e ) ; requestAnimationFrame ( ( ) => { requestAnimationFrame ( ( ) => observer . complete ( ) ) ; } ) ; } ) ; return ( ) => { if ( anim . playState !== 'finished' ) anim . cancel ( ) ; } ; } ) ; }
An observable wrapper for the WebAnimations API.
An observable wrapper for the WebAnimations API .