From aa0d97b933be53b65ca9e89b8787ef57729488df Mon Sep 17 00:00:00 2001 From: mbacalak Date: Tue, 12 Apr 2016 22:50:13 -0400 Subject: [PATCH 1/2] Fix for scrolling not working on mobile after adding image. --- src/angular-img-cropper.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/angular-img-cropper.js b/src/angular-img-cropper.js index 8dbb2e6..3564539 100644 --- a/src/angular-img-cropper.js +++ b/src/angular-img-cropper.js @@ -380,17 +380,17 @@ angular.module('angular-img-cropper', []).directive("imageCropper", ['$document' this.croppedImage = new Image(); this.currentlyInteracting = false; - angular.element(window) - .off('mousemove.angular-img-cropper mouseup.angular-img-cropper touchmove.angular-img-cropper touchend.angular-img-cropper') - .on('mousemove.angular-img-cropper', this.onMouseMove.bind(this)) - .on('mouseup.angular-img-cropper', this.onMouseUp.bind(this)) - .on('touchmove.angular-img-cropper', this.onTouchMove.bind(this)) + angular.element(window) + .off('mousemove.angular-img-cropper mouseup.angular-img-cropper') + .on('mousemove.angular-img-cropper', this.onMouseMove.bind(this)) + .on('mouseup.angular-img-cropper', this.onMouseUp.bind(this)); + + angular.element(canvas) + .off('mousedown.angular-img-cropper touchstart.angular-img-cropper touchmove.angular-img-cropper touchend.angular-img-cropper') + .on('mousedown.angular-img-cropper', this.onMouseDown.bind(this)) + .on('touchstart.angular-img-cropper', this.onTouchStart.bind(this)) + .on('touchmove.angular-img-cropper', this.onTouchMove.bind(this)) .on('touchend.angular-img-cropper', this.onTouchEnd.bind(this)); - - angular.element(canvas) - .off('mousedown.angular-img-cropper touchstart.angular-img-cropper') - .on('mousedown.angular-img-cropper', this.onMouseDown.bind(this)) - .on('touchstart.angular-img-cropper', this.onTouchStart.bind(this)); } ImageCropper.prototype.resizeCanvas = function (width, height) { From e8505baa4bcf56d9cbcf8de470d174fe1070b2a1 Mon Sep 17 00:00:00 2001 From: mbacalak Date: Thu, 14 Apr 2016 20:59:16 -0400 Subject: [PATCH 2/2] Remove Jquery requirement for event registration. --- src/angular-img-cropper.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/angular-img-cropper.js b/src/angular-img-cropper.js index 3564539..e34f5f6 100644 --- a/src/angular-img-cropper.js +++ b/src/angular-img-cropper.js @@ -380,17 +380,26 @@ angular.module('angular-img-cropper', []).directive("imageCropper", ['$document' this.croppedImage = new Image(); this.currentlyInteracting = false; - angular.element(window) - .off('mousemove.angular-img-cropper mouseup.angular-img-cropper') - .on('mousemove.angular-img-cropper', this.onMouseMove.bind(this)) - .on('mouseup.angular-img-cropper', this.onMouseUp.bind(this)); + if (window.jQuery) { + angular.element(window) + .off('mousemove.angular-img-cropper mouseup.angular-img-cropper') + .on('mousemove.angular-img-cropper', this.onMouseMove.bind(this)) + .on('mouseup.angular-img-cropper', this.onMouseUp.bind(this)); - angular.element(canvas) - .off('mousedown.angular-img-cropper touchstart.angular-img-cropper touchmove.angular-img-cropper touchend.angular-img-cropper') - .on('mousedown.angular-img-cropper', this.onMouseDown.bind(this)) - .on('touchstart.angular-img-cropper', this.onTouchStart.bind(this)) - .on('touchmove.angular-img-cropper', this.onTouchMove.bind(this)) - .on('touchend.angular-img-cropper', this.onTouchEnd.bind(this)); + angular.element(canvas) + .off('mousedown.angular-img-cropper touchstart.angular-img-cropper touchmove.angular-img-cropper touchend.angular-img-cropper') + .on('mousedown.angular-img-cropper', this.onMouseDown.bind(this)) + .on('touchstart.angular-img-cropper', this.onTouchStart.bind(this)) + .on('touchmove.angular-img-cropper', this.onTouchMove.bind(this)) + .on('touchend.angular-img-cropper', this.onTouchEnd.bind(this)); + } else { + window.addEventListener('mousemove', this.onMouseMove.bind(this)); + window.addEventListener('mouseup', this.onMouseUp.bind(this)); + canvas.addEventListener('mousedown', this.onMouseDown.bind(this)); + canvas.addEventListener('touchmove', this.onTouchMove.bind(this), false); + canvas.addEventListener('touchstart', this.onTouchStart.bind(this), false); + canvas.addEventListener('touchend', this.onTouchEnd.bind(this), false); + } } ImageCropper.prototype.resizeCanvas = function (width, height) {