Home
Quick setup, clear API
Works good out of the box and allows customization when you need it
Build for both direct in-browser usage and as an NPM module for inclusion in your project
npm install --save-dev defocuser
or
<script src="https://unpkg.com/defocuser"></script>
and then use it on the element you want to track outside clicks of:
<div id="my-dropdown">....</div>
const defocuser = new Defocuser()
const el = document.querySelector('#my-dropdown')
defocuser.addElement(el, 'bubbling', () => console.log('Clicked outside of #my-div'))