Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-cropperjs

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cropperjs

Ember wrapper around vanilla cropperjs

  • 0.9.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
802
decreased by-0.5%
Maintainers
2
Weekly downloads
 
Created
Source

ember-cropperjs

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.

Installation

ember install ember-cropperjs

Usage

{{! app/templates/application.hbs }}

<ImageCropper
  @source="sinbad2_800x600.jpg"
  @options={{hash aspectRatio=1 viewMode=2}}
  as |cropper|
>
  <cropper.on @event="crop" @action={{this.crop}} />
</ImageCropper>
// app/controllers/application.ts

import Controller from '@ember/controller';
import { debounce } from '@ember/runloop';
import { action } from '@ember/object';

export default class ApplicationController extends Controller {
  _updateFileBlob(cropper) {
    return cropper
      .getCroppedCanvas({
        // any additional options
        maxWidth: 512,
        maxHeight: 512,
      })
      .toBlob((blob) => {
        // do something with the blob:
        // common examples include `blob.readAsDataURL()` or `blob.readAsArrayBuffer()`
      });
  }

  @action crop(cropper) {
    // debounce is optional
    debounce(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

Running the dummy application

For more information on using ember-cli, visit https://ember-cli.com/.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 15 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc