Skip to content

Instantly share code, notes, and snippets.

@pixelhijack
Created March 19, 2014 08:52
Show Gist options
  • Save pixelhijack/9637897 to your computer and use it in GitHub Desktop.
Save pixelhijack/9637897 to your computer and use it in GitHub Desktop.
/*
extending Raphael.js: draggable sets
*/
Raphael.st.draggable = function() {
var _this = this,
lx = 0,
ly = 0,
ox = 0,
oy = 0,
move = function(dx, dy){
lx = dx + ox;
ly = dy + oy;
_this.transform('t' + lx + ',' + ly);
},
start = function() {
this.animate({opacity: 0.4}, 100, 'ease-out');
},
end = function() {
ox = lx;
oy = ly;
this.animate({opacity: 1}, 200, 'ease-in');
};
this.attr({cursor: "move"});
this.drag(move, start, end);
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment