Last active
December 10, 2015 22:08
-
-
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.
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
/** | |
* 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