tick.ts 443 B

12345678910111213141516171819202122
  1. import { nextTick } from 'vue'
  2. const tick = async (times: number) => {
  3. while (times--) {
  4. await nextTick()
  5. }
  6. }
  7. export default tick
  8. // in order to test transitions, we need to use
  9. // await rAF() after firing transition events.
  10. export const rAF = async () => {
  11. return new Promise((res) => {
  12. requestAnimationFrame(() => {
  13. requestAnimationFrame(async () => {
  14. res(null)
  15. await nextTick()
  16. })
  17. })
  18. })
  19. }