开发者

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;
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜