2020-09-10 19:07:24 +08:00
|
|
|
import { nextTick } from 'vue'
|
|
|
|
|
|
|
|
const tick = async (times: number) => {
|
|
|
|
while (times--) {
|
|
|
|
await nextTick()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default tick
|
2020-12-01 10:28:42 +08:00
|
|
|
|
|
|
|
// in order to test transitions, we need to use
|
|
|
|
// await rAF() after firing transition events.
|
|
|
|
export const rAF = async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
return new Promise((res) => {
|
2020-12-01 10:28:42 +08:00
|
|
|
requestAnimationFrame(() => {
|
2020-12-15 11:42:21 +08:00
|
|
|
requestAnimationFrame(async () => {
|
2021-01-14 17:01:37 +08:00
|
|
|
res(null)
|
2020-12-15 11:42:21 +08:00
|
|
|
await nextTick()
|
|
|
|
})
|
2020-12-01 10:28:42 +08:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|