Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

animationFrame.ts 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { AnimationFrameAction } from './AnimationFrameAction';
  2. import { AnimationFrameScheduler } from './AnimationFrameScheduler';
  3. /**
  4. *
  5. * Animation Frame Scheduler
  6. *
  7. * <span class="informal">Perform task when `window.requestAnimationFrame` would fire</span>
  8. *
  9. * When `animationFrame` scheduler is used with delay, it will fall back to {@link asyncScheduler} scheduler
  10. * behaviour.
  11. *
  12. * Without delay, `animationFrame` scheduler can be used to create smooth browser animations.
  13. * It makes sure scheduled task will happen just before next browser content repaint,
  14. * thus performing animations as efficiently as possible.
  15. *
  16. * ## Example
  17. * Schedule div height animation
  18. * ```ts
  19. * // html: <div style="background: #0ff;"></div>
  20. * import { animationFrameScheduler } from 'rxjs';
  21. *
  22. * const div = document.querySelector('div');
  23. *
  24. * animationFrameScheduler.schedule(function(height) {
  25. * div.style.height = height + "px";
  26. *
  27. * this.schedule(height + 1); // `this` references currently executing Action,
  28. * // which we reschedule with new state
  29. * }, 0, 0);
  30. *
  31. * // You will see a div element growing in height
  32. * ```
  33. */
  34. export const animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction);
  35. /**
  36. * @deprecated renamed. Use {@link animationFrameScheduler}
  37. */
  38. export const animationFrame = animationFrameScheduler;