1.0.2 • Published 5 years ago

react-image-cropping v1.0.2

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

react-image-crop

Image Crop component for React app based on Moveable

Install

if you use npm

npm install --save react-image-crop

or

yarn add react-image-crop

Usage

import ImageCrop from "react-image-crop";

class MyApp extends React.Component {
    state = { newImage: null }
    
    render () {
        return <ImageCrop 
            canDelete
            className="myapp-image-crop"
            imageUrl={this.state.newImage}
            onChange={({ target }) => this.setState({ newImage: target.result })}
            onDelete={() => this.setState({ newImage: null })}
            onSubmit={() => this.savePhoto()}
        />
    }
}

without photo with photo

Params

NameDefault valueRequiredDescription
onChangefunc: (event) => {}yesevent on change photo
onClosefunc: () => {}nofunction on closing crop
onDeletefunc: () => {}nofunction on delete photo
onSubmitfunc: (event, boundingImageRects) => {}yesfunction on click "submit"
imageUrlstringnoimage path for crop window
canDragbool: truenocan you drag image
canClosebool: falsenocan you close crop
canDeletebool: falsenocan you delete image
classNamestring: nonenoregular className property for react component
closeIconstringnourl of custom close icon
deleteIconstring: nonenourl of custom delete icon
deleteLabelstring: "Delete"nolabel for delete button
isLoadingbool: falsenoflag if you need loading spinner
plugIconstringnoimage if imageUrl is absent
submitLabelstring: "Save"nolabel for submit button
uploadPhotoLabelstring: "Upload photo"nolabel for upload photo button

Using libraries

  • jquery
  • prop-types
  • react-moveable

License

Copyright (c) 2019 Maria Lobareva Licensed under the The MIT License (MIT).