diff --git a/2.1/type/normal/imgcrop.js b/2.1/type/normal/imgcrop.js index 27e26c6..3f7f9cd 100644 --- a/2.1/type/normal/imgcrop.js +++ b/2.1/type/normal/imgcrop.js @@ -172,7 +172,8 @@ KISSY.add(function (S, Resize, Drag) { _onImgLoad:function () { this._initStyle(); this._setImgSize(); - this._setPos(); + this._setPos(); + if (this.get("ratio")) { this._adjustInitSize(); } this._initDrag(); this._initResize(); }, @@ -252,6 +253,19 @@ KISSY.add(function (S, Resize, Drag) { self.el.height(_wrapHeight - p.y); } }, + _adjustInitSize:function () { + var self = this, + _width = self.el.width(), + _height = self.el.height(), + _defRatio = self.get('initWidth')/self.get('initHeight'); //默认宽高比 + if (_defRatio!=1) { + if (_defRatio>1) { + self.el.width(_height*_defRatio); + } else { + self.el.height(_width/_defRatio); + } + } + }, //设置切割样式 _setPos:function () { var self = this;