mirror of
https://github.com/infeng/react-viewer.git
synced 2025-12-08 17:36:40 +00:00
fix: zoom error when pics res higher than screens res
This commit is contained in:
parent
5e45a8e130
commit
d1abef32bc
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
node_modules/
|
||||
dist/
|
||||
lib/
|
||||
lib/
|
||||
.DS_STORE
|
||||
@ -113,12 +113,12 @@ export default class ViewerCore extends React.Component<ViewerProps, ViewerCoreS
|
||||
getImgWidthHeight(imgWidth, imgHeight) {
|
||||
let width = 0;
|
||||
let height = 0;
|
||||
let aspectRatio = imgWidth / imgHeight;
|
||||
if (aspectRatio > 1) {
|
||||
width = Math.min(this.containerWidth * .8, imgWidth);
|
||||
height = (width / imgWidth) * imgHeight;
|
||||
}else {
|
||||
height = Math.min((this.containerHeight - this.footerHeight) * .8, imgHeight);
|
||||
let maxWidth = this.containerWidth * .8;
|
||||
let maxHeight = (this.containerHeight - this.footerHeight) * .8;
|
||||
width = Math.min(maxWidth, imgWidth);
|
||||
height = (width / imgWidth) * imgHeight;
|
||||
if (height > maxHeight) {
|
||||
height = maxHeight;
|
||||
width = (height / imgHeight) * imgWidth;
|
||||
}
|
||||
return [width, height];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user