From c506ff39e98566f33e60fb4501ac75a04af3467e Mon Sep 17 00:00:00 2001 From: infeng Date: Wed, 12 Dec 2018 10:19:10 +0800 Subject: [PATCH] refactor: resize behavior --- src/ViewerCore.tsx | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/ViewerCore.tsx b/src/ViewerCore.tsx index 64ae271..cc1e10c 100644 --- a/src/ViewerCore.tsx +++ b/src/ViewerCore.tsx @@ -138,6 +138,10 @@ export default class ViewerCore extends React.Component { this.setContainerWidthHeight(); if (this.props.visible) { - const [width, height] = this.getImgWidthHeight(this.state.imageWidth, this.state.imageHeight); - let left = (this.containerWidth - width) / 2; - let top = (this.containerHeight - height - this.footerHeight) / 2; + let left = (this.containerWidth - this.state.width) / 2; + let top = (this.containerHeight - this.state.height - this.footerHeight) / 2; this.setState({ - width: width, - height: height, left: left, top: top, - rotate: 0, - scaleX: 1, - scaleY: 1, }); } }