koel/resources/assets/js/directives/clickaway.ts
2022-04-30 13:55:54 +02:00

7 lines
224 B
TypeScript

import { Directive } from 'vue'
export const clickaway: Directive = {
created (el: HTMLElement, binding) {
document.addEventListener('click', (e: MouseEvent) => el.contains(e.target as Node) || binding.value())
}
}