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

Update fiximgclick.js #15

Open
wants to merge 1 commit 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
26 changes: 22 additions & 4 deletions _src/plugins/fiximgclick.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,30 @@ UE.plugins["fiximgclick"] = (function () {
},
updateTargetElement: function () {
var me = this;
// 拿到图片的原始大小
var o_width = me.target.naturalWidth;
var o_height = me.target.naturalHeight;

// 计算出原始图片比例
var o_scale = (o_width / o_height).toFixed(4);

// 再拿到图片现在的大小,可能是变形的Ï
var width = parseInt(me.resizer.style.width);
var height = parseInt(me.resizer.style.height);

// 判断改变的是宽度还是高度
if (rect[me.dragId][2] != 0) {
height = width / o_scale;
} else if (rect[me.dragId][3] != 0) {
width = height * o_scale;
}

domUtils.setStyles(me.target, {
width: me.resizer.style.width,
height: me.resizer.style.height
width: width + "px",
height: height + "px",
});
me.target.width = parseInt(me.resizer.style.width);
me.target.height = parseInt(me.resizer.style.height);
me.target.width = width;
me.target.height = height;
me.attachTo(me.target);
},
updateContainerStyle: function (dir, offset) {
Expand Down