Skip to content

Instantly share code, notes, and snippets.

@illustratordavid
Created November 3, 2014 14:19
Show Gist options
  • Select an option

  • Save illustratordavid/9c04484ac4facab64c3e to your computer and use it in GitHub Desktop.

Select an option

Save illustratordavid/9c04484ac4facab64c3e to your computer and use it in GitHub Desktop.
SnapSVG Plugin - Move element to centre of another element
Element.prototype.moveToCenter = function(centerTarget) {
var t = this.transform().localMatrix;
t.translate((centerTarget.getBBox().cx-(this.getBBox().width/2)),(centerTarget.getBBox().cy-(this.getBBox().height/2)));
this.transform(t);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment