Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用imgcrop发现个小问题 #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion 2.1/type/normal/imgcrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down Expand Up @@ -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;
Expand Down