landmine
v0.0.1
Published
Proximity trigger
Downloads
12
Readme
landmine
Proximity activated callbacks
Inspired by Alex Sexton's Blog
Usage
Include script
$ npm install landmine
Instantiate with callback, DOM element, and trigger distance
new Landmine(function(){
console.log('Proximity triggered');
// More actions i.e. AJAX
}, document.getElementById('bomb'), 200);
The above bind #bomb
to listen to the mousemove
event to determine whether
it is within the proximity range of the element. In this case, when the cursor
is within 200px from the element, the callback will be triggered.
Notes
- Only tested on Chrome and untested otherwise
- Make more robust and add defaults
- Test, test, tests
License
Landmine is released under the MIT License.