mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Add typings for croppie@2.4.0 (#13046)
This commit is contained in:
committed by
Mohamed Hegazy
parent
5c2fa5ca0e
commit
695e719764
26
croppie/croppie-tests.ts
Normal file
26
croppie/croppie-tests.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import Croppie from 'croppie';
|
||||
|
||||
const c = new Croppie(document.getElementById('item'), {
|
||||
boundary: { width: 300, height: 300 },
|
||||
viewport: { width: 100, height: 100 },
|
||||
showZoomer: false,
|
||||
enableOrientation: false,
|
||||
});
|
||||
|
||||
|
||||
c.bind({
|
||||
url: 'demo/demo-2.jpg',
|
||||
orientation: 4,
|
||||
zoom: 0,
|
||||
});
|
||||
|
||||
c.rotate(90);
|
||||
|
||||
c.setZoom(0.5);
|
||||
|
||||
c.result({ type: 'blob' }).then(blob => {
|
||||
let x: Blob;
|
||||
x = blob;
|
||||
});
|
||||
|
||||
c.destroy();
|
||||
52
croppie/index.d.ts
vendored
Normal file
52
croppie/index.d.ts
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
// Type definitions for croppie 2.4
|
||||
// Project: https://github.com/Foliotek/Croppie
|
||||
// Definitions by: Connor Peet <https://github.com/connor4312>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export default class Croppie {
|
||||
constructor(container: HTMLElement, options?: CroppieOptions);
|
||||
|
||||
bind(options: {
|
||||
url: string,
|
||||
points?: number[],
|
||||
orientation?: number,
|
||||
zoom?: number,
|
||||
useCanvas?: boolean,
|
||||
}): Promise<void>;
|
||||
|
||||
result(options: ResultOptions & { type: 'base64' }): Promise<string>;
|
||||
result(options: ResultOptions & { type: 'html' }): Promise<HTMLElement>;
|
||||
result(options: ResultOptions & { type: 'blob' }): Promise<Blob>;
|
||||
result(options: ResultOptions & { type: 'canvas' }): Promise<HTMLCanvasElement>;
|
||||
result(options?: ResultOptions): Promise<HTMLCanvasElement>;
|
||||
|
||||
rotate(degrees: 90 | 180 | 270 | -90 | -180 | -270): void;
|
||||
|
||||
setZoom(zoom: number): void;
|
||||
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
|
||||
export type CropType = 'square' | 'circle';
|
||||
|
||||
export type Format = 'jpeg' | 'png' | 'webp';
|
||||
|
||||
export interface ResultOptions {
|
||||
size?: 'viewport' | 'original' | { width: number, height: number };
|
||||
format?: Format;
|
||||
quality?: number;
|
||||
circle?: boolean;
|
||||
}
|
||||
|
||||
export interface CroppieOptions {
|
||||
boundary?: { width: number, height: number };
|
||||
customClass?: string;
|
||||
enableExif?: boolean;
|
||||
enableOrientation?: boolean;
|
||||
enableZoom?: boolean;
|
||||
enforceBoundary?: boolean;
|
||||
mouseWheelZoom?: boolean;
|
||||
showZoomer?: boolean;
|
||||
viewport?: { width: number, height: number, type?: CropType };
|
||||
}
|
||||
19
croppie/tsconfig.json
Normal file
19
croppie/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"croppie-tests.ts"
|
||||
]
|
||||
}
|
||||
1
croppie/tslint.json
Normal file
1
croppie/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user