UNPKG

7.19 kBTypeScriptView Raw
1import { ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnInit, SimpleChanges } from '@angular/core';
2import { DomSanitizer, HammerLoader, SafeStyle, SafeUrl } from '@angular/platform-browser';
3import { CropperPosition, Dimensions, ImageCroppedEvent, ImageTransform, LoadedImage } from '../interfaces';
4import { OutputFormat } from '../interfaces/cropper-options.interface';
5import { MoveTypes } from '../interfaces/move-start.interface';
6import { CropService } from '../services/crop.service';
7import { CropperPositionService } from '../services/cropper-position.service';
8import { LoadImageService } from '../services/load-image.service';
9import { BasicEvent } from "../interfaces/basic-event.interface";
10import * as i0 from "@angular/core";
11export declare class ImageCropperComponent implements OnChanges, OnInit {
12 private cropService;
13 private cropperPositionService;
14 private loadImageService;
15 private sanitizer;
16 private cd;
17 private zone;
18 private readonly hammerLoader;
19 private settings;
20 private setImageMaxSizeRetries;
21 private moveStart?;
22 private loadedImage?;
23 private resizedWhileHidden;
24 safeImgDataUrl?: SafeUrl | string;
25 safeTransformStyle?: SafeStyle | string;
26 marginLeft: SafeStyle | string;
27 maxSize: Dimensions;
28 moveTypes: typeof MoveTypes;
29 imageVisible: boolean;
30 wrapper: ElementRef<HTMLDivElement>;
31 sourceImage: ElementRef<HTMLDivElement>;
32 imageChangedEvent?: Event | null;
33 imageURL?: string;
34 imageBase64?: string;
35 imageFile?: File;
36 imageAltText?: string;
37 cropperFrameAriaLabel: string;
38 output: 'blob' | 'base64';
39 format: OutputFormat;
40 transform: ImageTransform;
41 maintainAspectRatio: boolean;
42 aspectRatio: number;
43 resetCropOnAspectRatioChange: boolean;
44 resizeToWidth: number;
45 resizeToHeight: number;
46 cropperMinWidth: number;
47 cropperMinHeight: number;
48 cropperMaxHeight: number;
49 cropperMaxWidth: number;
50 cropperStaticWidth: number;
51 cropperStaticHeight: number;
52 canvasRotation: number;
53 initialStepSize: number;
54 roundCropper: boolean;
55 onlyScaleDown: boolean;
56 imageQuality: number;
57 autoCrop: boolean;
58 backgroundColor: string | null;
59 containWithinAspectRatio: boolean;
60 hideResizeSquares: boolean;
61 allowMoveImage: boolean;
62 cropper: CropperPosition;
63 alignImage: 'left' | 'center';
64 disabled: boolean;
65 hidden: boolean;
66 imageCropped: EventEmitter<ImageCroppedEvent>;
67 startCropImage: EventEmitter<void>;
68 imageLoaded: EventEmitter<LoadedImage>;
69 cropperReady: EventEmitter<Dimensions>;
70 loadImageFailed: EventEmitter<void>;
71 transformChange: EventEmitter<ImageTransform>;
72 constructor(cropService: CropService, cropperPositionService: CropperPositionService, loadImageService: LoadImageService, sanitizer: DomSanitizer, cd: ChangeDetectorRef, zone: NgZone, hammerLoader: HammerLoader | null);
73 ngOnChanges(changes: SimpleChanges): void;
74 private onChangesUpdateSettings;
75 private onChangesInputImage;
76 private isValidImageChangedEvent;
77 private setCssTransform;
78 ngOnInit(): void;
79 private reset;
80 private loadImageFile;
81 private loadBase64Image;
82 private loadImageFromURL;
83 private setLoadedImage;
84 loadImageError(error: unknown): void;
85 imageLoadedInView(): void;
86 private checkImageMaxSizeRecursively;
87 private sourceImageLoaded;
88 onResize(): void;
89 private activatePinchGesture;
90 private resizeCropperPosition;
91 resetCropperPosition(): void;
92 keyboardAccess(event: KeyboardEvent): void;
93 private changeKeyboardStepSize;
94 private keyboardMoveCropper;
95 startMove(event: Event | BasicEvent, moveType: MoveTypes, position?: string | null): void;
96 private initMouseMove;
97 startPinch(event: any): void;
98 private handleMouseMove;
99 onPinch(event: any): void;
100 private setMaxSize;
101 private setCropperScaledMinSize;
102 private setCropperScaledMinWidth;
103 private setCropperScaledMinHeight;
104 private setCropperScaledMaxSize;
105 private checkCropperPosition;
106 private handleMouseUp;
107 pinchStop(): void;
108 private doAutoCrop;
109 crop(): ImageCroppedEvent | null;
110 crop(output: 'base64'): ImageCroppedEvent | null;
111 crop(output: 'blob'): Promise<ImageCroppedEvent> | null;
112 private cropToBlob;
113 private cropToBase64;
114 private aspectRatioIsCorrect;
115 static ɵfac: i0.ɵɵFactoryDeclaration<ImageCropperComponent, [null, null, null, null, null, null, { optional: true; }]>;
116 static ɵcmp: i0.ɵɵComponentDeclaration<ImageCropperComponent, "image-cropper", never, { "imageChangedEvent": { "alias": "imageChangedEvent"; "required": false; }; "imageURL": { "alias": "imageURL"; "required": false; }; "imageBase64": { "alias": "imageBase64"; "required": false; }; "imageFile": { "alias": "imageFile"; "required": false; }; "imageAltText": { "alias": "imageAltText"; "required": false; }; "cropperFrameAriaLabel": { "alias": "cropperFrameAriaLabel"; "required": false; }; "output": { "alias": "output"; "required": false; }; "format": { "alias": "format"; "required": false; }; "transform": { "alias": "transform"; "required": false; }; "maintainAspectRatio": { "alias": "maintainAspectRatio"; "required": false; }; "aspectRatio": { "alias": "aspectRatio"; "required": false; }; "resetCropOnAspectRatioChange": { "alias": "resetCropOnAspectRatioChange"; "required": false; }; "resizeToWidth": { "alias": "resizeToWidth"; "required": false; }; "resizeToHeight": { "alias": "resizeToHeight"; "required": false; }; "cropperMinWidth": { "alias": "cropperMinWidth"; "required": false; }; "cropperMinHeight": { "alias": "cropperMinHeight"; "required": false; }; "cropperMaxHeight": { "alias": "cropperMaxHeight"; "required": false; }; "cropperMaxWidth": { "alias": "cropperMaxWidth"; "required": false; }; "cropperStaticWidth": { "alias": "cropperStaticWidth"; "required": false; }; "cropperStaticHeight": { "alias": "cropperStaticHeight"; "required": false; }; "canvasRotation": { "alias": "canvasRotation"; "required": false; }; "initialStepSize": { "alias": "initialStepSize"; "required": false; }; "roundCropper": { "alias": "roundCropper"; "required": false; }; "onlyScaleDown": { "alias": "onlyScaleDown"; "required": false; }; "imageQuality": { "alias": "imageQuality"; "required": false; }; "autoCrop": { "alias": "autoCrop"; "required": false; }; "backgroundColor": { "alias": "backgroundColor"; "required": false; }; "containWithinAspectRatio": { "alias": "containWithinAspectRatio"; "required": false; }; "hideResizeSquares": { "alias": "hideResizeSquares"; "required": false; }; "allowMoveImage": { "alias": "allowMoveImage"; "required": false; }; "cropper": { "alias": "cropper"; "required": false; }; "alignImage": { "alias": "alignImage"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "hidden": { "alias": "hidden"; "required": false; }; }, { "imageCropped": "imageCropped"; "startCropImage": "startCropImage"; "imageLoaded": "imageLoaded"; "cropperReady": "cropperReady"; "loadImageFailed": "loadImageFailed"; "transformChange": "transformChange"; }, never, never, true, never>;
117}