Skip to content

Instantly share code, notes, and snippets.

Forked from fermion/hoverer.js
Created Apr 9, 2009
What would you like to do?
Hover class for Prototype
var Hoverer = {
current: null,
delay: 0.5,
timer: null,
handler: function(event) {
var element = event.findElement('div.nav_menu');
if (!element)
return Hoverer.leave();
if (element == Hoverer.current)
return Hoverer.stopTimer();
observe: function() {
document.observe('mouseover', Hoverer.handler);
stopObserving: function() {
document.stopObserving('mouseover', Hoverer.handler);
enter: function(element) {
if (Hoverer.current) Hoverer.fireMouseExited(Hoverer.current);'mouse:entered');
Hoverer.current = element;
leave: function() {
if (!Hoverer.current || Hoverer.timer) return;
Hoverer.timer = Hoverer.fireMouseExited.curry(Hoverer.current).delay(Hoverer.delay)
fireMouseExited: function(element) {'mouse:exited');
Hoverer.current = null;
stopTimer: function() {
if (!Hoverer.timer) return;
Hoverer.timer = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment