From 318670c492fe5214b89ade00ce9b77c05a810481 Mon Sep 17 00:00:00 2001 From: yao Date: Thu, 25 Aug 2016 15:02:23 +0800 Subject: [PATCH] Update TransformableImage.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a minScale prop makes the image scales minScale at least. In the case of that the Image size is same with the screen sizeļ¼Œ when i double-tap the image, i hope the image scale to the minScale instead of nothing happend. --- library/TransformableImage.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/library/TransformableImage.js b/library/TransformableImage.js index 6da1c08..60738fc 100644 --- a/library/TransformableImage.js +++ b/library/TransformableImage.js @@ -23,7 +23,8 @@ export default class TransformableImage extends Component { enableScale: PropTypes.bool, enableTranslate: PropTypes.bool, onTransformGestureReleased: PropTypes.func, - onViewTransformed: PropTypes.func + onViewTransformed: PropTypes.func, + minScale: PropTypes.number }; static defaultProps = { @@ -63,6 +64,7 @@ export default class TransformableImage extends Component { let maxScale = 1; let contentAspectRatio = undefined; let width, height; //pixels + const { minScale } = this.props; if (this.props.pixels) { //if provided via props @@ -78,11 +80,12 @@ export default class TransformableImage extends Component { contentAspectRatio = width / height; if (this.state.width && this.state.height) { maxScale = Math.max(width / this.state.width, height / this.state.height); - maxScale = Math.max(1, maxScale); + if(minScale){ + maxScale = Math.max(minScale, maxScale); + } } } - return (