Noteworthy Programming Masterpiece
Miss any of our Open RFC calls?Watch the recordings here! »

@wyhaya/react-crop-image

0.0.6 • Public • Published

react-crop-image

React crop image component

preview

Example

yarn dev

Install

yarn add @wyhaya/react-crop-image

Use

Component styles use styled-components

import Crop from '@wyhaya/react-crop-image'
 
<Crop
    // Picture url
    src={this.state.url}
    // Selected area: x y width height
    crop={this.state.crop}
    // Additional content
    element={<div>Crop</div>}
    // Default area
    onLoad={(crop, imageWidth, imageHeight) => this.setState({
        crop
    })}
    // Change area
    onChange={(crop) => this.setState({
        crop
    })}
/>

Type

type Crop = {
    x: number
    y: number
    width: number
    height: number
}
interface Props {
    src: string
    crop: Crop
    scale?: [number, number]
    width?: number
    height?: number
    minCropWidth?: number
    minCropHeight?: number
    element?: JSX.Element
    onLoad?: (crop: Crop, imageWidth: number, imageHeight: number) => void
    onChange?: (crop: Crop) => void
    className?: string
    style?: React.CSSProperties
}

Install

npm i @wyhaya/react-crop-image

DownloadsWeekly Downloads

9

Version

0.0.6

License

MIT

Unpacked Size

29.9 kB

Total Files

6

Last publish

Collaborators

  • avatar