Don't scale up images that are smaller than the screen.

This commit is contained in:
Timothy Farrell 2018-01-04 13:58:21 -06:00
parent 06e64dc730
commit dd4b2459ac

View File

@ -30,18 +30,22 @@ export function FocusView(vm, params, key, { appbar, appbarView }) {
({ width: iw, height: ih }, { width: vw, height: vh }) => { ({ width: iw, height: ih }, { width: vw, height: vh }) => {
const imageRatio = iw / ih; const imageRatio = iw / ih;
const windowRatio = vw / vh; const windowRatio = vw / vh;
if (iw < vw && ih < vh) {
return {
height: ih,
width: iw
};
}
if (windowRatio > imageRatio) { if (windowRatio > imageRatio) {
return { return {
height: vw / windowRatio, height: vw / windowRatio,
width: vw / windowRatio * imageRatio width: vw / windowRatio * imageRatio
}; };
} else { }
return { return {
height: vh * windowRatio / imageRatio, height: vh * windowRatio / imageRatio,
width: vh * windowRatio width: vh * windowRatio
}; };
}
}, },
[doc, fullViewportSize] [doc, fullViewportSize]
); );