1.0.0 • Published 4 years ago

a-antd-img-crop v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

antd-img-crop

An image cropper for Ant Design Upload.

npm npm npm bundle size GitHub

English | 简体中文

Demo

Live demo

Install

yarn add antd-img-crop

Usage

import ImgCrop from 'antd-img-crop';
import { Upload } from 'antd';

const Demo = () => (
  <ImgCrop>
    <Upload>+ Add image</Upload>
  </ImgCrop>
);

Props

PropTypeDefaultDescription
aspectnumber1 / 1Aspect of crop area , width / height
shapestring'rect'Shape of crop area, 'rect' or 'round'
gridbooleanfalseShow grid of crop area (third-lines)
zoombooleantrueEnable zoom for image
rotatebooleanfalseEnable rotate for image
beforeCropfunction-Called before modal open, if return false, it'll not open
modalTitlestring'Edit image'Title of modal
modalWidthnumber | string520Width of modal in pixels or percentages
modalOkstring'OK'Text of confirm button of modal
modalCancelstring'Cancel'Text of cancel button of modal
minZoomnumber1Minimum zoom factor
maxZoomnumber3Maximum zoom factor
restrictPositionbooleantrue if current zoom is at least 1, false otherwiseWhether the position of the media should be restricted to the boundaries of the cropper. Most useful when zoom factor is less than 1.

Styles

To prevent overwriting the custom styles to antd, antd-img-crop does not import the style files of components.

Therefore, if your project configured babel-plugin-import, and not use Modal or Slider, you need to import the styles yourself:

import 'antd/es/modal/style';
import 'antd/es/slider/style';

License

MIT License (c) nanxiaobei

1.0.1

4 years ago

1.0.0

4 years ago