- import { debounce } from '@/utils'
- export default function createResizeObserver(target, func) {
- let deFunc = null
- let first = true
- if(func) deFunc = debounce(() => {
- if(first) return (first = false)
- func()
- }, 100)
- const observer = new ResizeObserver((entries, observer) => {
- deFunc && deFunc()
- });
- observer.observe(target);
- return () => {
- observer.unobserve(target)
- }
- }