Created
September 27, 2012 23:46
-
-
Save asolove/3797132 to your computer and use it in GitHub Desktop.
State machine drag & drop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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