Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesssooi committed Jan 29, 2018
2 parents 0e91fc1 + b574baf commit cea38b0
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
59 changes: 59 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Type definitions for Croppr.js
// Definitions by: James Ooi https://github.com/jamesssooi
// Based on the template: https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-class-d-ts.html


/*~ Expose this module as a UMD */
export as namespace Croppr;

/*~ Specify the class constructor function */
export = Croppr;


declare class Croppr {

/** @constructor */
constructor(element: string | HTMLElement, options?: Croppr.CropprOptions, deferred?: boolean)

/** Gets the value of the crop region */
getValue(mode?: 'real' | 'ratio' | 'raw'): Croppr.CropprValue

/** Destroys the Croppr instance */
destroy(): void

/** Moves the crop region to a specified coordinate */
moveTo(x: number, y: number): Croppr

/** Resizes the crop region to a specified width and height */
resizeTo(width: number, height: number, origin?: Array<number>): Croppr

/** Scale the crop region by a factor */
scaleBy(factor: number, origin?: Array<number>): Croppr

/** Resets the crop region to the initial settings */
reset(): Croppr
}

/*~ Declare type modules */
declare namespace Croppr {

export interface CropprOptions {
aspectRatio?: number;
maxSize?: [number, number, '%' | 'px'];
minSize?: [number, number, '%' | 'px'];
startSize?: [number, number, '%' | 'px'];
onCropStart?(data: Croppr.CropprValue): void;
onCropMove?(data: Croppr.CropprValue): void;
onCropEnd?(data: Croppr.CropprValue): void;
onInitialize?(instance: Croppr): void;
returnMode?: 'real' | 'ratio' | 'raw';
}

export interface CropprValue {
x: number;
y: number;
width: number;
height: number
}

}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.1.0",
"description": "A vanilla JavaScript image cropper that's lightweight, awesome, and has absolutely zero dependencies.",
"main": "dist/croppr.js",
"typings": "./index.d.ts",
"scripts": {
"test": "mocha",
"build": "rollup --config rollup.config.dev.js & cp src/css/croppr.css dist/croppr.css",
Expand Down

0 comments on commit cea38b0

Please sign in to comment.