Socket
Book a DemoInstallSign in
Socket

canvas_cropjs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas_cropjs

a canvas cropper of Mobile end

0.2.3
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

cropjs

A cropper base on mobile.Use canvas show and crop.

example

example at https://cexoso.github.io/cropjs. Use mobile visit will be better.

api

get instance

import Crop from 'canvas_cropjs'
const crop = new Crop(ele, opt);

ele: string or DOM. The container crop will be in. If string is receipted, document.querySelector will be called to get a DOM.

opts:

  • cropOpts
{
    border: 1.3, // border aspect ratio
    left: 0.5, // 50%
    size: 0.6, // size of border box,Relative to width of canvas.
    top: 0.3, // 30%
}
statusOpts: {
        zoom: true
    },
    result: {
        type: 'base64',
        mimeType: '',
        quality: 1
    }
  • statusOpts
{
    zoom: true // Add clickable Element for scaling .
}
  • result
{
    type: 'base64' | 'blob' | 'all', // export base64,blob, of all of they.
    mimeType: 'image/png' | 'image/jpeg', // The mimeType of export blob
    quality: 1 // 0~1 quality
}

add eventListener

crop.addEventListener('crop', onCrop);
// cancel and crop can be Listened.

set img

set img to crop

const img = new Image();
img.src = URL.createObjectURL(file);
crop.setImg(Img);

reset

reset crop for next crop.

crop.reset();

show hide

show or hide the crop.

crop.show()
crop.hide()

development

  • run yarn or npm i to install Dependencies
  • run yarn start or npm start to open development environment.

depoly

The example folder includes exmaple source. And run yarn deploy will deploy example to homepage(https://cexoso.github.io/cropjs/).

FAQs

Package last updated on 30 Mar 2018

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.