Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created May 22, 2009 21:15
Show Gist options
  • Select an option

  • Save subtleGradient/116364 to your computer and use it in GitHub Desktop.

Select an option

Save subtleGradient/116364 to your computer and use it in GitHub Desktop.
// -*- Mode: MooTools Javascript; tab-width: 4; -*-
// Proposed syntax. Not fully functional atm.
/*
EG: a menu system
a menu is open while in the the menu-open state
when the menu-open state is removed, the menu should be closed
the menu-open state must be false 100 ms after the last mouseout even it fired
*/
var menuOpen = new State.Boolean('menuOpen');
var menuItems = $$('#nav .menu');
menuOpen.addEvents({
true: Elements.addClass.bind(menuItems, 'open'),
false: [
Elements.removeClass.bind(menuItems, 'open'),
Elements.addClass.bind(menuItems, 'closed')
]
});
menuItems.addEvents({
mouseenter: menuOpen.setTrue,
mouseout: menuOpen.setFalse
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment