initial: bootstrap from BukidBountyApp base

This commit is contained in:
Jonathan Sykes
2026-06-06 18:43:00 +08:00
commit eb4a5731fb
5674 changed files with 160857 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import { onMounted, onBeforeUnmount } from 'vue'
/**
* Watch for DOM changes on a target element and run a callback.
*
* @param {HTMLElement | null} targetElement - Element to monitor
* @param {Function} callback - Function to run on mutations
*/
export function useMutationObserver(targetElement, callback) {
let observer = null
onMounted(() => {
if (!targetElement) return
observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
callback()
}
})
})
observer.observe(targetElement, { childList: true, subtree: true })
})
onBeforeUnmount(() => {
if (observer) observer.disconnect()
})
}