Skip to content

Instantly share code, notes, and snippets.

@wycats
Forked from erichocean/behavior.js
Created February 4, 2011 01:22
Show Gist options
  • Save wycats/810573 to your computer and use it in GitHub Desktop.
Save wycats/810573 to your computer and use it in GitHub Desktop.
MyApp.MyBehavior = SC.Behavior.extend({
target: 'MyApp',
action: 'doSomething',
initialHandler: 'mouseUpNotOver',
mouseUpNotOver: SC.Handler.extend({
mouseEntered: 'mouseUpOver'
// no class name applied (in active)
}),
mouseUpOver: SC.Handler.extend({
classNames: 'hover',
mouseDown: 'mouseDownOver'
}),
mouseDownOver: SC.Handler.extend({
classNames: 'active over',
mouseExited: 'mouseDownOut',
mouseUp: function(evt) {
return this.performAction();
}
}),
mouseDownOut: SC.Handler.extend({
classNames: 'active out',
mouseEntered: 'mouseDownOver'
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment