diff --git a/examples/src/index.js b/examples/src/index.js index cd89e4e..c1721e6 100644 --- a/examples/src/index.js +++ b/examples/src/index.js @@ -13,6 +13,8 @@ class App extends React.Component { crop: { x: 0, y: 0 }, zoom: 1, aspect: 4 / 3, + cropShape: 'rect', + showGrid: true, } onCropChange = crop => { @@ -36,6 +38,8 @@ class App extends React.Component { crop={this.state.crop} zoom={this.state.zoom} aspect={this.state.aspect} + cropShape={this.state.cropShape} + showGrid={this.state.showGrid} onCropChange={this.onCropChange} onCropComplete={this.onCropComplete} onZoomChange={this.onZoomChange} diff --git a/src/index.js b/src/index.js index 3c7b840..9312b31 100644 --- a/src/index.js +++ b/src/index.js @@ -245,7 +245,10 @@ class Cropper extends React.Component { const { crop: { x, y }, zoom, + cropShape, + showGrid, } = this.props + return ( {this.state.cropSize && ( ({ + ...(() => { + switch (cropShape) { + case 'round': + return { ...cropperArea, ...roundShape } + case 'rect': + default: + return cropperArea + } + })(), + ...(showGrid ? gridLines : {}), +}))