Updated image editor with not having to crop again after resizing

This commit is contained in:
Erik Tiekstra
2017-05-23 09:03:29 +02:00
parent 30e49c95c8
commit 5f9169ef51
7 changed files with 50 additions and 31 deletions
+5 -11
View File
@@ -23,20 +23,14 @@
Event.handleResize();
});
function getOptimalDimension(currentDimension, ratio) {
var width = $input.w.val();
var height = $input.h.val();
function getOptimalDimension(values, currentDimension, ratio) {
if (currentDimension === 'h') {
width = Math.round(height / ratio);
values.width = Math.round(values.height * ratio);
} else {
height = Math.round(width / ratio);
values.height = Math.round(values.width / ratio);
}
return {
width: width,
height: height
};
return values;
}
var Event = {
@@ -70,7 +64,7 @@
handleResize: function() {
var isFullScreen = document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement;
var width = $wrapper.width();
var height = isFullScreen ? $window.height() : $wrapper.height();
var height = isFullScreen ? ($window.height() < 800 ? $window.height() : 800) : $wrapper.height();
editor.canvas.resize({width: width, height: height});
}
};