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.ButtonBehavior = SC.Behavior.extend({
target: 'MyApp',
action: 'doSomething',
initialHandler: 'mouseUpNotOver',
mouseUpNotOver: SC.State.extend({
mouseEntered: 'mouseUpOver'
// no class name applied (in active)
}),
mouseUpOver: SC.State.extend({
classNames: 'hover',
mouseDown: 'mouseDownOver',
mouseExited: 'mouseUpNotOver'
}),
mouseDownOver: SC.State.extend({
classNames: 'active over',
mouseExited: 'mouseDownOut',
mouseUp: function(e) { this.performAction(); this.transitionTo('mouseUpOver'); }
}),
mouseDownOut: SC.State.extend({
classNames: 'active out',
mouseEntered: 'mouseDownOver'
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment