YesPlayMusic/packages/preload/utils.ts

17 lines
408 B
TypeScript
Raw Normal View History

2022-03-13 14:40:38 +08:00
/** Document ready */
export const domReady = (
condition: DocumentReadyState[] = ['complete', 'interactive']
) => {
return new Promise(resolve => {
if (condition.includes(document.readyState)) {
resolve(true)
} else {
document.addEventListener('readystatechange', () => {
if (condition.includes(document.readyState)) {
resolve(true)
}
})
}
})
}