about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/ui/components/media_modal.js
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-11-05 06:02:49 -0600
committerFire Demon <firedemon@creature.cafe>2020-11-05 06:02:49 -0600
commit4e187f6f004b9c4b1a05aa0c721bd674871d4401 (patch)
treec1fa6a2845dba645bec19ed9e5d5cc88fdf8e61c /app/javascript/flavours/glitch/features/ui/components/media_modal.js
parentfa982ae8d7118c20aa145312b36096a453eeb695 (diff)
parent5a9fc749c3eab8d3c93dd282fa89c20a5cb0e994 (diff)
Merge remote-tracking branch 'upstream/master' into dev
Diffstat (limited to 'app/javascript/flavours/glitch/features/ui/components/media_modal.js')
-rw-r--r--app/javascript/flavours/glitch/features/ui/components/media_modal.js24
1 files changed, 21 insertions, 3 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 aa6554107..e37df7208 100644
--- a/app/javascript/flavours/glitch/features/ui/components/media_modal.js
+++ b/app/javascript/flavours/glitch/features/ui/components/media_modal.js
@@ -35,23 +35,39 @@ class MediaModal extends ImmutablePureComponent {
   state = {
     index: null,
     navigationHidden: false,
+    zoomButtonHidden: false,
   };
 
   handleSwipe = (index) => {
     this.setState({ index: index % this.props.media.size });
   }
 
+  handleTransitionEnd = () => {
+    this.setState({
+      zoomButtonHidden: false,
+    });
+  }
+
   handleNextClick = () => {
-    this.setState({ index: (this.getIndex() + 1) % this.props.media.size });
+    this.setState({
+      index: (this.getIndex() + 1) % this.props.media.size,
+      zoomButtonHidden: true,
+    });
   }
 
   handlePrevClick = () => {
-    this.setState({ index: (this.props.media.size + this.getIndex() - 1) % this.props.media.size });
+    this.setState({
+      index: (this.props.media.size + this.getIndex() - 1) % this.props.media.size,
+      zoomButtonHidden: true,
+    });
   }
 
   handleChangeIndex = (e) => {
     const index = Number(e.currentTarget.getAttribute('data-index'));
-    this.setState({ index: index % this.props.media.size });
+    this.setState({
+      index: index % this.props.media.size,
+      zoomButtonHidden: true,
+    });
   }
 
   handleKeyDown = (e) => {
@@ -128,6 +144,7 @@ class MediaModal extends ImmutablePureComponent {
             alt={image.get('description')}
             key={image.get('url')}
             onClick={this.toggleNavigation}
+            zoomButtonHidden={this.state.zoomButtonHidden}
           />
         );
       } else if (image.get('type') === 'video') {
@@ -191,6 +208,7 @@ class MediaModal extends ImmutablePureComponent {
             style={swipeableViewsStyle}
             containerStyle={containerStyle}
             onChangeIndex={this.handleSwipe}
+            onTransitionEnd={this.handleTransitionEnd}
             index={index}
           >
             {content}