add modal and clickoutside
This commit is contained in:
15
src/shared/clickOutside.js
Normal file
15
src/shared/clickOutside.js
Normal file
@@ -0,0 +1,15 @@
|
||||
export const clickOutside = {
|
||||
mounted: (el, binding) => {
|
||||
el.clickOutsideEvent = (event) => {
|
||||
if (!(el === event.target || el.contains(event.target))) {
|
||||
binding.value();
|
||||
}
|
||||
};
|
||||
document.addEventListener("click", el.clickOutsideEvent, { capture: true });
|
||||
},
|
||||
unmounted: (el) => {
|
||||
document.removeEventListener("click", el.clickOutsideEvent, {
|
||||
capture: true,
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user