koel/resources/assets/js/directives/clickaway.ts

8 lines
224 B
TypeScript
Raw Normal View History

import { Directive } from 'vue'
2022-04-15 14:24:30 +00:00
export const clickaway: Directive = {
2022-04-30 11:55:54 +00:00
created (el: HTMLElement, binding) {
document.addEventListener('click', (e: MouseEvent) => el.contains(e.target as Node) || binding.value())
2022-04-15 14:24:30 +00:00
}
}