From 11eb7f6e48997e7011dcef196e0b017577a04bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=87=82=E8=B1=A1?= Date: Thu, 6 Mar 2014 11:11:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E5=AE=BD=E9=AB=98?= =?UTF-8?q?=E6=AF=94=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=97=B6=E5=80=99=EF=BC=8C=5FonImgLoad=E4=B8=AD=5Fset?= =?UTF-8?q?Pos=E4=BC=9A=E5=AF=BC=E8=87=B4=E5=A4=B1=E5=8E=BB=E5=8E=9F?= =?UTF-8?q?=E6=9C=89=E5=AE=BD=E9=AB=98=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2.1/type/normal/imgcrop.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/2.1/type/normal/imgcrop.js b/2.1/type/normal/imgcrop.js index 27e26c6..6d2eb62 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._adjustInitPos(); } this._initDrag(); this._initResize(); }, @@ -252,6 +253,19 @@ KISSY.add(function (S, Resize, Drag) { self.el.height(_wrapHeight - p.y); } }, + _adjustInitPos: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; From 6633cb96ca33521902a2ea2041398540ebd62971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=87=82=E8=B1=A1?= Date: Thu, 6 Mar 2014 11:45:52 +0800 Subject: [PATCH 2/2] meaningful func name --- 2.1/type/normal/imgcrop.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2.1/type/normal/imgcrop.js b/2.1/type/normal/imgcrop.js index 6d2eb62..3f7f9cd 100644 --- a/2.1/type/normal/imgcrop.js +++ b/2.1/type/normal/imgcrop.js @@ -173,7 +173,7 @@ KISSY.add(function (S, Resize, Drag) { this._initStyle(); this._setImgSize(); this._setPos(); - if (this.get("ratio")) { this._adjustInitPos(); } + if (this.get("ratio")) { this._adjustInitSize(); } this._initDrag(); this._initResize(); }, @@ -253,7 +253,7 @@ KISSY.add(function (S, Resize, Drag) { self.el.height(_wrapHeight - p.y); } }, - _adjustInitPos:function () { + _adjustInitSize:function () { var self = this, _width = self.el.width(), _height = self.el.height(),