Skip to content

Commit

Permalink
[cmd:resize] fix Studio-42#628 resize calculation problem
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Jul 2, 2013
1 parent e701aa1 commit a45b0b6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions js/commands/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ elFinder.prototype.commands.resize = function() {
width = $(input)
.change(function() {
var w = parseInt(width.val()),
h = parseInt(cratio ? w/ratio : height.val());
h = parseInt(cratio ? Math.round(w/ratio) : height.val());

if (w > 0 && h > 0) {
resize.updateView(w, h);
Expand All @@ -102,7 +102,7 @@ elFinder.prototype.commands.resize = function() {
height = $(input)
.change(function() {
var h = parseInt(height.val()),
w = parseInt(cratio ? h*ratio : width.val());
w = parseInt(cratio ? Math.round(h*ratio) : width.val());

if (w > 0 && h > 0) {
resize.updateView(w, h);
Expand Down Expand Up @@ -213,8 +213,8 @@ elFinder.prototype.commands.resize = function() {
},
resize = {
update : function() {
width.val(parseInt(img.width()/prop));
height.val(parseInt(img.height()/prop));
width.val(Math.round(img.width()/prop));
height.val(Math.round(img.height()/prop));
},

updateView : function(w, h) {
Expand Down Expand Up @@ -242,7 +242,7 @@ elFinder.prototype.commands.resize = function() {
var w, h;
if (cratio) {
h = height.val();
h = parseInt(h*ratio);
h = Math.round(h*ratio);
resize.updateView(w, h);
width.val(w);
}
Expand All @@ -251,28 +251,28 @@ elFinder.prototype.commands.resize = function() {
var w, h;
if (cratio) {
w = width.val();
h = parseInt(w/ratio);
h = Math.round(w/ratio);
resize.updateView(w, h);
height.val(h);
}
}
},
crop = {
update : function() {
offsetX.val(parseInt(rhandlec.width()/prop));
offsetY.val(parseInt(rhandlec.height()/prop));
pointX.val(parseInt((rhandlec.offset().left-imgc.offset().left)/prop));
pointY.val(parseInt((rhandlec.offset().top-imgc.offset().top)/prop));
offsetX.val(Math.round(rhandlec.width()/prop));
offsetY.val(Math.round(rhandlec.height()/prop));
pointX.val(Math.round((rhandlec.offset().left-imgc.offset().left)/prop));
pointY.val(Math.round((rhandlec.offset().top-imgc.offset().top)/prop));
},
updateView : function() {
var w = parseInt(offsetX.val() * prop);
var h = parseInt(offsetY.val() * prop);
var w = Math.round(offsetX.val() * prop);
var h = Math.round(offsetY.val() * prop);
rhandlec.width(w);
rhandlec.height(h);
coverc.width(rhandlec.width());
coverc.height(rhandlec.height());
rhandlec.offset({left: parseInt(pointX.val()) * prop + imgc.offset().left,
top: parseInt(pointY.val()) * prop + imgc.offset().top});
rhandlec.offset({left: Math.round(pointX.val()) * prop + imgc.offset().left,
top: Math.round(pointY.val()) * prop + imgc.offset().top});
},
resize_update : function() {
crop.update();
Expand Down

0 comments on commit a45b0b6

Please sign in to comment.