Skip to content

Instantly share code, notes, and snippets.

@c4urself
Last active December 10, 2015 22:08
Show Gist options
  • Save c4urself/4500114 to your computer and use it in GitHub Desktop.
Save c4urself/4500114 to your computer and use it in GitHub Desktop.
A function that moves a path -- has the nice side-effect of making SVG paths with different starting points behave the same way.
/**
* Move path method // hack for getting all svg icons
* working the same way
*/
var movePath = function (x, y) {
var path = Raphael.pathToRelative(this.attrs.path),
dim = Raphael.pathBBox(this.attrs.path),
dx = (path[0][1] - dim.x) + (x * 100),
dy = (path[0][2] - dim.y) + (y * 100);
path[0][1] = dx;
path[0][2] = dy;
return this.attr({path: path});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment