Skip to content

Commit eece52a

Browse files
committed
Replace new Promise() by angular $q()
- fix andyshora#28
1 parent 4bf4042 commit eece52a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

image-crop.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@
759759
})();
760760

761761
angular.module('ImageCropper',[])
762-
.directive('imageCrop', function() {
762+
.directive('imageCrop', function($q) {
763763

764764
return {
765765
template: '<div id="image-crop-{{ rand }}" class="ng-image-crop ng-image-crop--{{ shape }}" ng-style="moduleStyles"><section ng-style="sectionStyles" ng-show="step==1"></section><section ng-style="sectionStyles" ng-show="step==2"><canvas class="cropping-canvas" width="{{ canvasWidth }}" height="{{ canvasHeight }}" ng-mousemove="onCanvasMouseMove($event)" ng-mousedown="onCanvasMouseDown($event)"></canvas><div ng-style="croppingGuideStyles" class="cropping-guide"></div><div class="zoom-handle" ng-mousemove="onHandleMouseMove($event)" ng-mousedown="onHandleMouseDown($event)" ng-mouseup="onHandleMouseUp($event)"><span>&larr; zoom &rarr;</span></div></section><section ng-style="sectionStyles" class="image-crop-section-final" ng-show="step==3"><img class="image-crop-final" ng-src="{{ croppedDataUri }}" /></section></div>',
@@ -806,7 +806,7 @@
806806
var maxZoomGestureLength = 0;
807807
var maxZoomedInLevel = 0, maxZoomedOutLevel = 2;
808808
var minXPos = 0, maxXPos = (padding/2), minYPos = 0, maxYPos = (padding/2); // for dragging bounds
809-
var maxSize = scope.maxSize ? Number(scope.maxSize) : null; //max size of the image in px
809+
var maxSize = scope.maxSize ? Number(scope.maxSize) : null; //max size of the image in px
810810

811811
var zoomWeight = .6;
812812
var ctx = $canvas.getContext('2d');
@@ -833,7 +833,7 @@
833833

834834
function handleSize(base64ImageSrc) {
835835

836-
return new Promise(function(resolve, reject) {
836+
return $q(function(resolve, reject) {
837837

838838
if(!maxSize) {
839839
return resolve(base64ImageSrc);
@@ -889,7 +889,7 @@
889889

890890
function handleEXIF(base64ImageSrc, exif) {
891891

892-
return new Promise(function(resolve, reject) {
892+
return $q(function(resolve, reject) {
893893

894894
var img = new Image();
895895
img.src = base64ImageSrc;
@@ -1341,4 +1341,4 @@
13411341
});
13421342

13431343

1344-
})();
1344+
})();

0 commit comments

Comments
 (0)