You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This addon provides a wrapper around Cropper.js as well as two yielded components for handling events and programatically calling methods on the cropper instance.
// app/controllers/application.tsimportControllerfrom'@ember/controller';import{debounce}from'@ember/runloop';import{action}from'@ember/object';exportdefaultclassApplicationControllerextendsController{_updateFileBlob(cropper){returncropper.getCroppedCanvas({// any additional optionsmaxWidth: 512,maxHeight: 512,}).toBlob((blob)=>{// do something with the blob:// common examples include `blob.readAsDataURL()` or `blob.readAsArrayBuffer()`});}
@actioncrop(cropper){// debounce is optionaldebounce(this,this._updateFileBlob,cropper,100);}}
Note: Any options available from Cropper.js are available to be passed in to the options hash. There seems to be an issue with Cropper processing Ember's Empty Object, so the components/image-cropper.js file copies the options object as a work around.
Contributing
Installation
git clone <repository-url>
cd my-addon
yarn
Linting
yarn run lint:js
yarn run lint:js -- --fix
Running tests
ember test – Runs the test suite on the current Ember version
ember test --server – Runs the test suite in "watch mode"
ember try:each – Runs the test suite against multiple Ember versions