Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update TransformableImage.js #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions library/TransformableImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -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 (
<ViewTransformer
ref='viewTransformer'
Expand Down Expand Up @@ -178,4 +181,4 @@ function sameSource(source, nextSource) {
}
}
return false;
}
}