liluxdev / ngx-cropperjs

CropperJS integration for Angular 7+
MIT License
0 stars 1 forks source link

Reset aspectRatio on active cropper #4

Open robtown opened 5 years ago

robtown commented 5 years ago

How would I reset the active cropper? I want to change aspect ration on the crop box.

This is how it would be done in JS: cropper.destroy(); cropper = new Cropper(image, options);

.destroy() is there on the ViewChild object.

But how create the new Cropper?

robtown commented 5 years ago

This seems to work: import * as Cropper from 'cropperjs/dist/cropper';

then: if (this.angularCropper) { // Restart this.cropperConfig["aspectRatio"] = this.currentFeaturedItem.HeroTypeId == 163 ? 1.3333 : 2.25; this.angularCropper.cropper.destroy(); $('.img-preview').html('') let temp = this.angularCropper.imageElement; this.angularCropper.cropper = new Cropper(temp, this.cropperConfig); }