Git Product home page Git Product logo

ember-cli-image-cropper's Introduction

Ember CLI Image Cropper Build Status

This Ember CLI addon that wraps the jQuery Cropper into an ember component.

It requires cropper

Installation

For ember-cli 1.13.1 and above. use ember-cli-image-cropper version 0.0.7 and beyond. To install it just use

# install via ember-cli
$ ember install ember-cli-image-cropper

For ember-cli 0.2.7 and below use ember-cli-image-cropper version 0.0.6 and install it using:

# install via ember-cli
$ ember install:addon ember-cli-image-cropper

Usage

The component initialises cropper when the image is loaded. To use it, extend the component and change the default to your preference. Currently no methods are provided by the addon. To do this you have to use the default cropper methods. For more about available methods checkout Cropper.

An example below show how to extend the component and get the croped canvas area.

Example:

// app/components/avatar-cropper.js
import imageCropper from 'ember-cli-image-cropper/components/image-cropper';

export default imageCropper.extend({
  //override default options of cropper
  aspectRatio: 1,
  minCropBoxWidth: 100,
  minCropBoxHeight: 100,
  cropperContainer: '.cropper-container > img',
  previewClass: '.img-preview',
  croppedAvatar: null,

  actions: {
    getCroppedAvatar: function() {
      var container = this.$(this.get('cropperContainer'));
      var croppedImage = container.cropper('getCroppedCanvas');
      this.set('croppedAvatar', croppedImage);
    }
  }
});

please note that in the extended component's template you should have an image tag inside a DOM element with a class 'cropper-container' Other wise, you chould also override the default cropperContainer : '.cropper-container > img'

Default Options

Cropper's default options are rewritten in the component as following.

previewClass: '.cropper-preview',
cropperContainer: '.cropper-container > img',
aspectRatio: 16 / 9,
crop: null,
viewMode: 0, // default crop box is within the container other options (1,2,3) check cropper documentation for more.
dragMode: 'crop',  // default crop. other options are 'move' and 'none'
responsive: true,
checkCrossOrigin: true,
background: true,
modal: true,
guides: true,
highlight: true,
autoCrop: true,
autoCropArea: 0.8,
dragDrop: true,
movable: true,
resizable: true,
zoomable: true,
zoomOnWheel: true,
zoomOnTouch: true,
toggleDragModeOnDblclick: true,
rotateable: true,
minContainerWidth: 200,
minContainerHeight: 100,
minCropBoxWidth: 0,
minCropBoxHeight: 0,
build: null,
built: null,
dragStart: null,
dragMove: null,
dragEnd: null,
zoomin: null,
zoomout: null,

For more options and methods, please check cropper's readd me.

ember-cli-image-cropper's People

Contributors

mhretab avatar klaser avatar estshy avatar raytiley avatar imkikus avatar rastopyr avatar

Watchers

JJ Parker avatar Chad Gartner avatar Christian Bechette avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.