element-plus/packages/directives/resize/index.ts
三咲智子 eb932c18c0
fix(components): [el-menu] fix warn & listen item (#3225)
* feat(directives): resize add element argument

* fix(components): [el-menu] fix warn & listen item

* chore: move import order

* fix(components): remove debounce
2021-09-04 19:44:11 +08:00

21 lines
421 B
TypeScript

import {
addResizeListener,
removeResizeListener,
} from '@element-plus/utils/resize-event'
import type { ObjectDirective } from 'vue'
const Resize: ObjectDirective = {
beforeMount(el, binding) {
el._handleResize = () => {
el && binding.value?.(el)
}
addResizeListener(el, el._handleResize)
},
beforeUnmount(el) {
removeResizeListener(el, el._handleResize)
},
}
export default Resize