7838deaa7f575198549a60b0ccdda9c997e6fdada317337ce924d234c7c2580a76225f877eec8526861dc215683c2de681c31d14ebfbbbd76ed36c78463874 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 to {@link animationFrameScheduler}. Will be removed in v8.
  37. */
  38. export const animationFrame = animationFrameScheduler;