Skip to content

Instantly share code, notes, and snippets.

@asolove
Created September 27, 2012 23:46
Show Gist options
  • Save asolove/3797132 to your computer and use it in GitHub Desktop.
Save asolove/3797132 to your computer and use it in GitHub Desktop.
State machine drag & drop
var Dragger = StatefulView.extend({
states: {
"dragging": function(e){ el.css({ opacity: 0.5 }) },
"inactive": function(e){ el.css({ opacity: 1 }); }
},
transitions: {
"mousedown .handle": ["inactive", "dragging"],
"mouseup": ["dragging", "inactive"],
"mousemove": ["dragging", "dragging", function(e){
el.css({ left: e.pageX, top: e.pageY });
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment