croppersvm

1.0.6 • Public • Published

cropperSVM

This package is an extension that was created for cropperjs plugin in order to have a new view mode that allows you to limit the cropping options into the inner edges of the cropbox.

It never allows the image to have shorter sides than the cropbox on all four sides in the same moment.

Simple implementation example:

import { specialViewMode } from 'croppersvm';

var image = document.getElementById('image');
var cropper = new Cropper(image, {
  aspectRatio: 16 / 9,
  viewMode: 0,
  crop: function(e) {
    var cropBox = cropper.getCropBoxData();
    var canvas = cropper.getCanvasData();

    var newCanvasData = specialViewMode(canvas, cropBox);

    if (newCanvasData.hasOwnProperty('width') ||
        newCanvasData.hasOwnProperty('left') ||
        newCanvasData.hasOwnProperty('top')
    ) {
        cropper.setCanvasData(newCanvasData);
    }
  }
});

Readme

Keywords

Package Sidebar

Install

npm i croppersvm

Weekly Downloads

0

Version

1.0.6

License

MIT

Unpacked Size

3.24 kB

Total Files

3

Last publish

Collaborators

  • peti562
  • shahafan