0.0.6 • Published 4 years ago

@wyhaya/react-crop-image v0.0.6

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

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
}
0.0.6

4 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago