@seniorsistemas/angular-components 17.3.6 → 17.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/seniorsistemas-angular-components.umd.js +36 -8
- package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
- package/components/utils/image-utils.d.ts +4 -0
- package/esm2015/components/image-cropper/image-cropper.component.js +13 -9
- package/esm2015/components/utils/image-utils.js +25 -0
- package/esm5/components/image-cropper/image-cropper.component.js +14 -9
- package/esm5/components/utils/image-utils.js +25 -0
- package/fesm2015/seniorsistemas-angular-components.js +36 -9
- package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
- package/fesm5/seniorsistemas-angular-components.js +37 -9
- package/fesm5/seniorsistemas-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/seniorsistemas-angular-components.metadata.json +1 -1
|
@@ -12803,6 +12803,30 @@
|
|
|
12803
12803
|
return StructureModule;
|
|
12804
12804
|
}());
|
|
12805
12805
|
|
|
12806
|
+
var ImageUtils;
|
|
12807
|
+
(function (ImageUtils) {
|
|
12808
|
+
function adjustAspectRatio(imageBase64) {
|
|
12809
|
+
return new rxjs.Observable(function (observer) {
|
|
12810
|
+
var image = new Image();
|
|
12811
|
+
image.src = imageBase64;
|
|
12812
|
+
image.onload = function () {
|
|
12813
|
+
var canvas = document.createElement('canvas');
|
|
12814
|
+
var context = canvas.getContext('2d');
|
|
12815
|
+
var size = Math.max(image.naturalWidth, image.naturalHeight);
|
|
12816
|
+
canvas.width = size;
|
|
12817
|
+
canvas.height = size;
|
|
12818
|
+
context.fillStyle = 'rgba(0, 0, 0, 0)';
|
|
12819
|
+
context.fillRect(0, 0, size, size);
|
|
12820
|
+
context.drawImage(image, (size - image.naturalWidth) / 2, (size - image.naturalHeight) / 2);
|
|
12821
|
+
var adjustedImageBase64 = canvas.toDataURL();
|
|
12822
|
+
observer.next(adjustedImageBase64);
|
|
12823
|
+
observer.complete();
|
|
12824
|
+
};
|
|
12825
|
+
});
|
|
12826
|
+
}
|
|
12827
|
+
ImageUtils.adjustAspectRatio = adjustAspectRatio;
|
|
12828
|
+
})(ImageUtils || (ImageUtils = {}));
|
|
12829
|
+
|
|
12806
12830
|
var ImageCropperComponent = /** @class */ (function () {
|
|
12807
12831
|
function ImageCropperComponent() {
|
|
12808
12832
|
this.id = "s-image-cropper-" + ImageCropperComponent_1.nextId++;
|
|
@@ -12838,16 +12862,20 @@
|
|
|
12838
12862
|
}
|
|
12839
12863
|
};
|
|
12840
12864
|
ImageCropperComponent.prototype.initCropper = function () {
|
|
12865
|
+
var _this = this;
|
|
12841
12866
|
if (this.cropper)
|
|
12842
12867
|
this.cropper.destroy();
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12868
|
+
ImageUtils.adjustAspectRatio(this.imageSource)
|
|
12869
|
+
.subscribe(function (imageBase64) {
|
|
12870
|
+
_this.image.nativeElement.src = imageBase64;
|
|
12871
|
+
_this.cropper = new Cropper(_this.image.nativeElement, {
|
|
12872
|
+
aspectRatio: _this.rounded ? 1 : _this.aspectRatio,
|
|
12873
|
+
guides: false,
|
|
12874
|
+
dragMode: "move",
|
|
12875
|
+
minCropBoxHeight: 2,
|
|
12876
|
+
minCropBoxWidth: 2,
|
|
12877
|
+
toggleDragModeOnDblclick: false,
|
|
12878
|
+
});
|
|
12851
12879
|
});
|
|
12852
12880
|
};
|
|
12853
12881
|
ImageCropperComponent.prototype.getRoundedCanvas = function (sourceCanvas) {
|