Created
May 24, 2014 10:04
-
-
Save vird/6dace7407951c0e4e465 to your computer and use it in GitHub Desktop.
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
for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) { | |
if (method == "rotate") { | |
setproto[method] = (function (methodname) { | |
return function () { | |
var arg = arguments; | |
if (arg.length == 1) { // only deg is present, cx and cy are missing | |
var bbox = this.getBBox(); | |
arg = [arg[0], (bbox.x+bbox.x2)/2, (bbox.y+bbox.y2)/2]; | |
} | |
return this.forEach(function (el) { | |
el[methodname].apply(el, arg); | |
}); | |
}; | |
})(method); | |
} else if (method == "scale") { | |
setproto[method] = (function (methodname) { | |
return function () { | |
var arg = arguments; | |
if (arg.length == 2) { // only sx,sy is present, cx and cy are missing | |
var bbox = this.getBBox(); | |
arg = [arg[0], arg[1], (bbox.x+bbox.x2)/2, (bbox.y+bbox.y2)/2]; | |
} | |
return this.forEach(function (el) { | |
el[methodname].apply(el, arg); | |
}); | |
}; | |
})(method); | |
} else { | |
setproto[method] = (function (methodname) { | |
return function () { | |
var arg = arguments; | |
return this.forEach(function (el) { | |
el[methodname].apply(el, arg); | |
}); | |
}; | |
})(method); | |
} | |
} |
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
for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) { | |
setproto[method] = (function (methodname) { | |
return function () { | |
var arg = arguments; | |
return this.forEach(function (el) { | |
el[methodname].apply(el, arg); | |
}); | |
}; | |
})(method); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment