Reverse jquery resize shift functionality
When you resize a div using jquery resize plugin, if you hold the shift key the aspect ratio is kept.
Well it is possible to {aspectRatio: true} to option list and if i hold开发者_运维知识库 the shift key to disable the aspect ratio ?
Thanks.
Well i managed by modifying the widget:
replaced
if (this._aspectRatio || b.shiftKey)
with
if (this._aspectRatio && !b.shiftKey)
You can monkey-patch the jquery resizable code for that without touching the source file, so you could still use its CDN.
var mouseDrag = $.ui.resizable.prototype._mouseDrag;
$.ui.resizable.prototype._mouseDrag = function (event) {
event.shiftKey = !event.shiftKey;
var aspectRatio = this._aspectRatio;
this._aspectRatio = aspectRatio && event.shiftKey;
mouseDrag.apply(this, arguments);
this._aspectRatio = aspectRatio;
};
精彩评论