This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let containerClass = "containerClass"; | |
| let insideContainer = false; | |
| let elem = event.target; | |
| while (elem) { | |
| if (elem.classList && elem.classList.contains(containerClass)) { | |
| insideContainer = true; | |
| break; | |
| } | |
| elem = elem.parentNode; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function addClickOutside(el: HTMLElement, fun: Function) { | |
| const elWithFun: HTMLElement & { | |
| clickOutsideFun?: (this: Document, ev: MouseEvent) => any; | |
| } = el; | |
| elWithFun.clickOutsideFun = function (this: Document, event: MouseEvent) { | |
| if (!el.contains(event.target as Node)) { | |
| fun(event); | |
| } | |
| return true as any; | |
| }; |