A simple outside click listener with no external dependencies.
- Super Tiny (Just 300 bytes)
- Support for multiple inside elements
- Disable dynamically
# yarn
yarn add @varld/outside-click
# npm
npm install --save @varld/outside-click
import outsideClick from '@varld/outside-click';
outsideClick(element, (clickEvent) => {
console.log('Someone clicked outside!');
});
The element(s) to attache the outside-click listener to. This can be a single HTMLElement
or an array of HTMLElement
.
This callback will be called, when an outside-click occurs.
An optional function which disables the outside-click listener if it returns false.
MIT © Tobias Herber