Skip to content

Commit

Permalink
Add typedef for options object
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorejb committed Nov 9, 2023
1 parent 7fa5941 commit 384e7a3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cropt.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ function loadImage(src) {
});
}

/**
* @typedef {object} ViewportOption
* @property {number} [width=200]
* @property {number} [height=200]
* @property {"square" | "circle"} [type="square"]
*/

/**
* @typedef {object} CroptOptions
* @property {"off" | "on" | "ctrl"} [mouseWheelZoom="on"]
* @property {ViewportOption=} viewport
* @property {string=} zoomerInputClass
*/

export class Cropt {
static defaults = {
viewport: {
Expand All @@ -129,6 +143,7 @@ export class Cropt {

/**
* @param {HTMLElement} element
* @param {CroptOptions} options
*/
constructor(element, options) {
if (element.classList.contains('cropt-container')) {
Expand Down Expand Up @@ -232,10 +247,13 @@ export class Cropt {
this.#updatePropertiesFromImage();
}

/**
* @param {CroptOptions} options
*/
setOptions(options) {
const curWidth = this.options.viewport.width;
const curHeight = this.options.viewport.height;

this.options = deepExtend(this.options, options);
this.#setOptionsCss();

Expand Down

0 comments on commit 384e7a3

Please sign in to comment.