From a4fa8c9064702167412a39901811430822440d11 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sun, 8 Apr 2018 23:18:24 +0200 Subject: [PATCH] [Glitch] Avoid using JS to set height in MediaModal Port fa5c867e0ec426fc01653e9022ba29783b2a826f to glitch-soc --- .../features/ui/components/media_modal.js | 35 ++++++++++--------- .../glitch/styles/components/media.scss | 13 ++++--- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/javascript/flavours/glitch/features/ui/components/media_modal.js b/app/javascript/flavours/glitch/features/ui/components/media_modal.js index 5353b62db..6ab6770ed 100644 --- a/app/javascript/flavours/glitch/features/ui/components/media_modal.js +++ b/app/javascript/flavours/glitch/features/ui/components/media_modal.js @@ -130,6 +130,15 @@ export default class MediaModal extends ImmutablePureComponent { return null; }).toArray(); + // you can't use 100vh, because the viewport height is taller + // than the visible part of the document in some mobile + // browsers when it's address bar is visible. + // https://developers.google.com/web/updates/2016/12/url-bar-resizing + const swipeableViewsStyle = { + width: '100%', + height: '100%', + }; + const containerStyle = { alignItems: 'center', // center vertically }; @@ -145,23 +154,15 @@ export default class MediaModal extends ImmutablePureComponent { role='presentation' onClick={onClose} > -
- - {content} - -
+ + {content} +
diff --git a/app/javascript/flavours/glitch/styles/components/media.scss b/app/javascript/flavours/glitch/styles/components/media.scss index 31dbb7f58..588e8d558 100644 --- a/app/javascript/flavours/glitch/styles/components/media.scss +++ b/app/javascript/flavours/glitch/styles/components/media.scss @@ -171,8 +171,12 @@ img, canvas, video { - max-width: 100vw; - max-height: 100vh; + max-width: 100%; + /* + put margins on top and bottom of image to avoid the screen coverd by + image. + */ + max-height: 80%; width: auto; height: auto; margin: auto; @@ -184,11 +188,6 @@ background: url('~images/void.png') repeat; object-fit: contain; } - - .react-swipeable-view-container { - width: 100vw; - height: 100%; - } } .media-modal__closer {