UNPKG

ngx-super-croppie

Version:

NgxSuperCroppie is a simple angular8+ wrapper for croppie

168 lines (161 loc) 6.42 kB
import * as i0 from '@angular/core'; import { Injectable, EventEmitter, Component, ViewChild, Input, Output, NgModule } from '@angular/core'; import Croppie from 'croppie'; class NgxSuperCroppieService { constructor() { } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: NgxSuperCroppieService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: NgxSuperCroppieService, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: NgxSuperCroppieService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: () => [] }); /** * wrapper for croppie * @packageDocumentation */ class NgxSuperCroppieComponent { constructor() { /** * Array of points that translate into [topLeftX, topLeftY, bottomRightX, bottomRightY] */ this.points = null; /** * Custom orientation, applied after exif orientation (if enabled). * Only works with enableOrientation option enabled (see 'Options'). * * Valid options are: * 1 unchanged * 2 flipped horizontally * 3 rotated 180 degrees * 4 flipped vertically * 5 flipped horizontally, then rotated left by 90 degrees * 6 rotated clockwise by 90 degrees * 7 flipped horizontally, then rotated right by 90 degrees * 8 rotated counter-clockwise by 90 degrees */ this.orientation = null; /** * Apply zoom after image has been bound */ this.zoom = 0; /** * event emitted to parent */ this.result = new EventEmitter(); } get url() { return this._url; } set url(url) { if (this._url === url) { return; } this._url = url; if (this._croppie) { this.bind(); } } /** * init cropper */ ngOnInit() { this._croppie = new Croppie(this.croppie.nativeElement, this.croppieOptions); this.bind(); } /** * get crop data * @returns crop points, and the zoom of the image. */ get() { return this._croppie.get(); } /** * Bind an image to the croppie. * Returns a promise to be resolved when the image has been loaded * and the croppie has been initialized. */ async bind() { await this._croppie.bind({ url: this.url, points: this.points, orientation: this.orientation, zoom: this.zoom, }); } /** * Destroy a croppie instance and remove it from the DOM */ destroy() { this._croppie.destroy(); } /** * emits croppie result to parent */ async croppieResult() { const result = await this._croppie.result(this.resultOptions); this.result.emit(result); } /** * Rotate the image by a specified degree amount. * Only works with enableOrientation option enabled (see 'Options') * @param degrees degrees of rotation */ rotate(degrees) { this._croppie.rotate(degrees); } /** * Set the zoom of a Croppie instance. The value passed in is * still restricted to the min/max set by Croppie. * @param zoom zoom value */ setZoom(zoom) { this._croppie.setZoom(zoom); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: NgxSuperCroppieComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: NgxSuperCroppieComponent, selector: "ngx-super-croppie", inputs: { croppieOptions: "croppieOptions", url: "url", points: "points", orientation: "orientation", zoom: "zoom", resultOptions: "resultOptions" }, outputs: { result: "result" }, viewQueries: [{ propertyName: "croppie", first: true, predicate: ["croppie"], descendants: true, static: true }], ngImport: i0, template: "<div #croppie (update)=\"croppieResult()\"></div>\r\n", styles: [""] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: NgxSuperCroppieComponent, decorators: [{ type: Component, args: [{ selector: 'ngx-super-croppie', template: "<div #croppie (update)=\"croppieResult()\"></div>\r\n" }] }], propDecorators: { croppie: [{ type: ViewChild, args: ['croppie', { static: true }] }], croppieOptions: [{ type: Input }], url: [{ type: Input }], points: [{ type: Input }], orientation: [{ type: Input }], zoom: [{ type: Input }], resultOptions: [{ type: Input }], result: [{ type: Output }] } }); class NgxSuperCroppieModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: NgxSuperCroppieModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.9", ngImport: i0, type: NgxSuperCroppieModule, declarations: [NgxSuperCroppieComponent], exports: [NgxSuperCroppieComponent] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: NgxSuperCroppieModule }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: NgxSuperCroppieModule, decorators: [{ type: NgModule, args: [{ declarations: [NgxSuperCroppieComponent], imports: [], exports: [NgxSuperCroppieComponent], }] }] }); /* * Public API Surface of ngx-super-croppie */ /** * Generated bundle index. Do not edit. */ export { NgxSuperCroppieComponent, NgxSuperCroppieModule, NgxSuperCroppieService }; //# sourceMappingURL=ngx-super-croppie.mjs.map