Closed
Description
I'm submitting a...
[X ] Bug report
Current behavior
With the introduction of typescript in 1.3.0, the Cropper.options dragMode
is now defined as a type DragMode. Unfortunately, setting it to the constant value (see code below) will then fail at runtime with following error:
console.js:35 ERROR TypeError: Cannot read property 'Move' of undefined
Expected behavior
No error. A possible solution is maybe to set dragMode as string
?
export interface Options {
...
dragMode?: string; // instead of DragMode
...
}
Minimal reproduction of the problem with instructions
import Cropper from 'cropperjs';
this.cropper = new Cropper(myUrl, {
viewMode: 2,
aspectRatio: 1,
dragMode: Cropper.DragMode.Move, // <-- Here the problem. Enum is not converted and will fail at runtime
modal: true,
guides: false,
highlight: true,
background: true,
autoCrop: true,
autoCropArea: 0.9,
responsive: true,
ready: (event: CustomEvent) => {
}
});
Environment
Cropper.js version: 1.3.1
Workaround
Right now, I have then declared dragMode like following to bypass the problem
import Cropper from 'cropperjs';
this.cropper = new Cropper(myUrl, {
...
dragMode: <any> 'move',
...
ready: (event: CustomEvent) => {
}
});
Metadata
Metadata
Assignees
Labels
No labels