diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.controller.js index e4a7bd5267..3f07c4bcb6 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.controller.js @@ -1,6 +1,6 @@ angular.module('umbraco') .controller("Umbraco.PropertyEditors.ImageCropperController", - function ($scope, fileManager) { + function ($scope, fileManager, $timeout) { var config = angular.copy($scope.model.config); @@ -127,15 +127,32 @@ angular.module('umbraco') /** * crop a specific crop - * @param {any} crop + * @param {any} targetCrop */ - function crop(crop) { - // clone the crop so we can discard the changes - $scope.currentCrop = angular.copy(crop); - $scope.currentPoint = null; + function crop(targetCrop) { + if (!$scope.currentCrop) { + // clone the crop so we can discard the changes + $scope.currentCrop = angular.copy(targetCrop); + $scope.currentPoint = null; - //set form to dirty to track changes - $scope.imageCropperForm.$setDirty(); + //set form to dirty to track changes + $scope.imageCropperForm.$setDirty(); + } + else { + // we have a crop open already - close the crop (this will discard any changes made) + close(); + + // the crop editor needs a digest cycle to close down properly, otherwise its state + // is reused for the new crop... and that's really bad + $timeout(function () { + crop(targetCrop); + $scope.pendingCrop = false; + }); + + // this is necessary to keep the screen from flickering too badly while we wait for the new crop to open + // - check the view for its usage (basically it makes sure we keep the space reserved for the new crop) + $scope.pendingCrop = true; + } }; /** done cropping */ diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.html index 4f46f4c5ae..7438fa04da 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/imagecropper/imagecropper.html @@ -12,10 +12,10 @@