From 024378e3aec3bfeecf5c2c26b6ef82e7898f903e Mon Sep 17 00:00:00 2001 From: Timothy Farrell Date: Thu, 4 Jan 2018 13:58:21 -0600 Subject: [PATCH] Don't scale up images that are smaller than the screen. --- packages/gallery/src/interface/focus.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/gallery/src/interface/focus.js b/packages/gallery/src/interface/focus.js index 70c33ca..10e1b78 100644 --- a/packages/gallery/src/interface/focus.js +++ b/packages/gallery/src/interface/focus.js @@ -30,18 +30,22 @@ export function FocusView(vm, params, key, { appbar, appbarView }) { ({ width: iw, height: ih }, { width: vw, height: vh }) => { const imageRatio = iw / ih; const windowRatio = vw / vh; - + if (iw < vw && ih < vh) { + return { + height: ih, + width: iw + }; + } if (windowRatio > imageRatio) { return { height: vw / windowRatio, width: vw / windowRatio * imageRatio }; - } else { - return { - height: vh * windowRatio / imageRatio, - width: vh * windowRatio - }; } + return { + height: vh * windowRatio / imageRatio, + width: vh * windowRatio + }; }, [doc, fullViewportSize] );