mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-10 17:42:50 +08:00
27 lines
658 B
TypeScript
27 lines
658 B
TypeScript
export function removeEl(selector: string) {
|
|
if (selector) {
|
|
const el = document.querySelector(selector)
|
|
el?.parentNode?.removeChild(el)
|
|
}
|
|
}
|
|
|
|
export function useDefer(maxFrameCount = 1) {
|
|
const frameCount = ref(0)
|
|
const refreshFrameCount = () => {
|
|
requestAnimationFrame(() => {
|
|
frameCount.value++
|
|
if (frameCount.value < maxFrameCount) refreshFrameCount()
|
|
})
|
|
}
|
|
refreshFrameCount()
|
|
return function (showInFrameCount: number) {
|
|
return frameCount.value >= showInFrameCount
|
|
}
|
|
}
|
|
|
|
export function ensureRenderComplete(callback: () => void) {
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(callback)
|
|
})
|
|
}
|