bcabanes / angular-image-cropper

AngularJS directive for cropping images.
124 stars 62 forks source link

Uncaught TypeError: self.applyZoom is not a function #29

Closed pietrovismara closed 8 years ago

pietrovismara commented 8 years ago

Every time i try to zoomIn/Out i get this error: Uncaught TypeError: self.applyZoom is not a function

In fact in the code, there is no applyZoom function! We just have this:

Cropper.prototype.bindControls = function() {
  var self = this;  
  this.elements.controls.zoomIn.addEventListener('click', function() {
    self.applyZoom(self.zoomInFactor);
  });
  this.elements.controls.zoomOut.addEventListener('click', function() {
    self.applyZoom(self.zoomOutFactor);
  });
};

Cropper.prototype.applyZoomIn = function(zoom) {
  this.zoomImage(1 + parseFloat(zoom));
};
Cropper.prototype.applyZoomOut = function(zoom) {
  this.zoomImage(1 / ( 1 + parseFloat(zoom)));
};

Then i went on the demo page to look at the code and i saw this:

Cropper.prototype.bindControls = function() {
  var self = this;
  this.elements.controls.zoomIn.addEventListener('click', function() {
    self.applyZoom(self.zoomInFactor);
  });
  this.elements.controls.zoomOut.addEventListener('click', function() {
    self.applyZoom(self.zoomOutFactor);
  });
};

Cropper.prototype.applyZoom = function(zoom) {
  this.zoomImage(zoom);
};

This code is working, everything is fine. But where do i get this code? I tried bower, npm and git but no way to find a working version. Can you help me?

bcabanes commented 8 years ago

Hi @pietrovismara What is the package version you use?

pietrovismara commented 8 years ago

I tried with bower and it installed this version: "ng-image-cropper": "https://npmcdn.com/angular-image-cropper/bower.zip#^1.1.6"

With npm: "angular-image-cropper": "^1.1.6"

Also i looked on the code on the github repo, and it looks like the same version.

bigfree commented 8 years ago

@pietrovismara change:

this.elements.controls.zoomIn.addEventListener('click', function() {
    self.applyZoom(self.zoomInFactor);
});
this.elements.controls.zoomOut.addEventListener('click', function() {
    self.applyZoom(self.zoomOutFactor);
});

to:

this.elements.controls.zoomIn.addEventListener('click', function() {
    self.applyZoomIn(self.zoomInFactor);
});
this.elements.controls.zoomOut.addEventListener('click', function( {
    self.applyZoomOut(self.zoomOutFactor);
});
pietrovismara commented 8 years ago

+1 please merge this commit and update the npm / bower packages so that we can start using this package.

bcabanes commented 8 years ago

Hi guys! I've merge the PR and this is in the new release! @KarlDoyle Thank you for your PR!