0.0.17 • Published 8 months ago

pekon-multiple-crops v0.0.17

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

React Multi Crops

A multiple cropping component for React

comment: <> (online demo(https://beizhedenglong.github.io/pekon-multiple-crops/))

comment: <> (kumamon(./examples/imgs/kumamon.gif))

Installation

npm install pekon-multiple-crops --save

Usage

import React from 'react'
import ReactDOM from 'react-dom'
import MultiCrops from 'pekon-multiple-crops'
import img from './imgs/kumamon.jpg'

class App extends React.Component {
  state = {
    coordinates: [],
  }

  changeCoordinate = (coordinate, index, coordinates) => {
    this.setState({
      coordinates,
    })
  }
  deleteCoordinate = (coordinate, index, coordinates) => {
    this.setState({
      coordinates,
    })
  }
  render() {
    return
        <MultiCrops
          src={img}
          color={"blue"}
          width={1000}
          coordinates={this.state.coordinates}
          onChange={this.changeCoordinate}
          onDelete={this.deleteCoordinate}
        />
      </div>
  }
}


ReactDOM.render(
  <div>
    <App />
  </div>,
  document.getElementById('root'),
)

Props

PropDescriptionTypeDefault
idid of image.string-
srcSrc of background image.string-
colorcolor of theme.string-
coordinatesAn array of coordinate( see the table blew), {id, x, y, width, height}.array[]
widthWidth of background image.number(in pixel)-
heightHeight of background image.number(in pixel)-
onDrawA callback which hanppends when a user starts drawing a new rectangle.funtion(coordinate , index, coordinates)-
onDragA callback which hanppends when a user stars draging a exited rectangle.funtion(coordinate , index, coordinates)-
onResizeA callback which hanppends when a user starts resizing a exited rectangle.funtion(coordinate , index, coordinates)-
onChangeA callback which hanppends when a user starts drawing, draging or resizing a new/exited rectangle.funtion(coordinate , index, coordinates)-
onDeleteA callback which hanppends when a user delete a exited rectangle.funtion(coordinate , index, coordinates)-
onLoadThe callback is triggered when the background image is loaded.onLoad(e)-

coordinate

PropDescriptionTypeDefault
idUnique between in coordinates arraystring-
xX coordinate relative to left corner(0,0) of background image. From left to right, x will go up.number(in pixel)-
yY coordinate relative to left corner(0,0) of background image. From top to bottom, y will go up.number(in pixel)-
widthWidth of coordinatenumber(in pixel)-
heightHeight of coordinatenumber(in pixel)-
0.0.17

8 months ago

0.0.16

8 months ago

0.0.15

8 months ago

0.0.14

8 months ago

0.0.13

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago