From 1bea3181975f377bbccfe92691e2cd281b298ec6 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 15 Aug 2019 20:28:56 +0200 Subject: [PATCH] Fix edit media modal on small screens, touch events (#11573) --- .../features/ui/components/focal_point_modal.js | 17 ++++++++++++++++- app/javascript/styles/mastodon/basics.scss | 2 +- app/javascript/styles/mastodon/components.scss | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/features/ui/components/focal_point_modal.js b/app/javascript/mastodon/features/ui/components/focal_point_modal.js index f7a5efda3..2f5c728a7 100644 --- a/app/javascript/mastodon/features/ui/components/focal_point_modal.js +++ b/app/javascript/mastodon/features/ui/components/focal_point_modal.js @@ -84,6 +84,14 @@ class FocalPointModal extends ImmutablePureComponent { this.setState({ dragging: true }); } + handleTouchStart = e => { + document.addEventListener('touchmove', this.handleMouseMove); + document.addEventListener('touchend', this.handleTouchEnd); + + this.updatePosition(e); + this.setState({ dragging: true }); + } + handleMouseMove = e => { this.updatePosition(e); } @@ -95,6 +103,13 @@ class FocalPointModal extends ImmutablePureComponent { this.setState({ dragging: false }); } + handleTouchEnd = () => { + document.removeEventListener('touchmove', this.handleMouseMove); + document.removeEventListener('touchend', this.handleTouchEnd); + + this.setState({ dragging: false }); + } + updatePosition = e => { const { x, y } = getPointerPosition(this.node, e); const focusX = (x - .5) * 2; @@ -225,7 +240,7 @@ class FocalPointModal extends ImmutablePureComponent {
-
+
)} diff --git a/app/javascript/styles/mastodon/basics.scss b/app/javascript/styles/mastodon/basics.scss index 7b983efab..f9332caa3 100644 --- a/app/javascript/styles/mastodon/basics.scss +++ b/app/javascript/styles/mastodon/basics.scss @@ -150,7 +150,7 @@ button { .layout-single-column .app-holder { &, & > div { - min-height: 100%; + min-height: 100vh; } } diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 7f0bf9fed..e30b75495 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -5757,6 +5757,11 @@ noscript { position: relative; cursor: move; overflow: hidden; + height: 100%; + display: flex; + justify-content: center; + align-items: center; + background: $base-shadow-color; img, video { @@ -5807,6 +5812,17 @@ noscript { box-shadow: 0 0 14px rgba($base-shadow-color, 0.2); } } + + @media screen and (max-width: 480px) { + img, + video { + max-height: 100%; + } + + &__preview { + display: none; + } + } } .account__header__content {