Skip to content

Instantly share code, notes, and snippets.

@vird
Created May 24, 2014 10:04
Show Gist options
  • Save vird/6dace7407951c0e4e465 to your computer and use it in GitHub Desktop.
Save vird/6dace7407951c0e4e465 to your computer and use it in GitHub Desktop.
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);
}
}
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