ontobox
v0.2.0
Published
Minimal utility to detect mouse hovers onto and off of 'popup' boxes"
Downloads
7
Maintainers
Readme
ontobox 
This is a very light implementation of the algorithm behind Amazon's "mega dropdown" tailored at more generic use cases--not just menus. It provides an object that simply takes an object to attach to, and lets you know when it should be closed.
It is compatible with but does not depend on jQuery, or any other external libraries, and compresses down under 800 bytes.
Example
var OntoBox = require('ontobox');
new OntoBox({
target: $el,
onclose: function () {
$el.remove();
},
});API
new OntoBox(options)
Attaches a new hover watcher. Options:
targeta DOM Node or jQuery object that is the target of the hover.onclosean event called when the element should be destroyed (or hover state lost).thresholdafter hovering, the number of pixels away from the target the mouse can stray beforeoncloseis called.
ontobox.recalculate()
Re-checks the sizing and position of the target element. This is called automatically when the window is resized, and if you suspect the element size might have changed otherwise this should be called.
ontobox.destroy()
Removes listeners associated with the ontobox instance. This is called automatically when onclose is fired (but calling it again doesn't hurt).
