1.0.2 • Published 7 years ago

outside-clicky v1.0.2

Weekly downloads
6
License
ISC
Repository
github
Last release
7 years ago

OutsideClicky

Listen for clicks outside of an element

Install

npm install outside-clicky --save

Usage

Initializing OutsideClicky

// Require OutsideClicky
const OutsideClicky = require('outside-clicky');
    
// Get the target element 
let myDiv = document.querySelector('.js-myDiv');
    
// Create a callback function that runs when you click outside of your target element
let myCallbackFunction = function () {
	console.log('You clicked outside myDiv');
};
    
// Initialize OutsideClicky
let myOC = new OutsideClicky();

Binding the listener

myOC.bind(myDiv, myCallbackFunction);

Unbinding the listener

myOC.unbind();

Automatically unbind after outside click

myOC.bind(myDiv, myCallbackFunction, true);
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago