From bc503bbaf909f1869437f67460ea0f38f9774562 Mon Sep 17 00:00:00 2001 From: MattyBalaam Date: Fri, 3 Aug 2018 13:50:48 +0100 Subject: [PATCH 1/2] Add props to set custom min and max zoom levels --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 68015bd..7fdf8ae 100644 --- a/src/index.js +++ b/src/index.js @@ -164,7 +164,7 @@ class Cropper extends React.Component { } setNewZoom = zoom => { - const newZoom = Math.min(MAX_ZOOM, Math.max(zoom, MIN_ZOOM)) + const newZoom = Math.min(this.props.minZoom, Math.max(zoom, this.props.maxZoom)) this.props.onZoomChange && this.props.onZoomChange(newZoom) } @@ -237,6 +237,8 @@ class Cropper extends React.Component { Cropper.defaultProps = { zoom: 1, aspect: 4 / 3, + maxZoom: MAX_ZOOM, + minZoom: MIN_ZOOM, } export default Cropper From 7ec0a3e38c2ddbb39e66d87b2b4a9727dba50c19 Mon Sep 17 00:00:00 2001 From: MattyBalaam Date: Fri, 3 Aug 2018 15:41:49 +0100 Subject: [PATCH 2/2] flip maxZoom and minZoom --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7fdf8ae..03c1f11 100644 --- a/src/index.js +++ b/src/index.js @@ -164,7 +164,7 @@ class Cropper extends React.Component { } setNewZoom = zoom => { - const newZoom = Math.min(this.props.minZoom, Math.max(zoom, this.props.maxZoom)) + const newZoom = Math.min(this.props.maxZoom, Math.max(zoom, this.props.minZoom)) this.props.onZoomChange && this.props.onZoomChange(newZoom) }