Package Exports
- react-image-crop
- react-image-crop/dist/ReactCrop
- react-image-crop/dist/ReactCrop.css
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-image-crop) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
React image crop
A responsive image cropping tool for React.
Features
- Responsive
- Touch enabled
- Free-form or fixed aspect crops
- Keyboard support for nudging selection
- Min/max crop size
Usage
Include the main js module, e.g.:
var ReactCrop = require('react-image-crop');
// or es6:
import ReactCrop from 'react-image-crop';
Include either dist/ReactCrop.css
or ReactCrop.scss
.
Props
src (required)
<ReactCrop src='path/to/image.jpg' />
You can of course pass a blob path or base64 data.
crop (optional)
All crop values are in percentages, and are relative to the image. All crop params are optional.
var crop = {
x: 20,
y: 10,
width: 30,
height: 10
}
<ReactCrop src='path/to/image.jpg' crop={crop} />
If you want a fixed aspect you only need to specify a width or a height:
var crop = {
width: 30,
aspect: 16/9
}
..Or you can omit both and only specify the aspect.
minWidth (optional)
A minimum crop width.
minHeight (optional)
A minimum crop height.
onChange(crop) (optional)
A callback which happens for every change of the crop (i.e. many times as you are dragging/resizing). Passes the current crop state object.
onComplete(crop) (optional)
A callback which happens after a resize, drag, or nudge. Passes the current crop state object.