about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/ui/index.js
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-08-25 15:48:50 +0200
committerEugen Rochko <eugen@zeonfederated.com>2019-08-25 15:48:50 +0200
commitbd4099d976b52f7ec00e00b23cfe6e2766ff1e4d (patch)
tree860f1511dbcf179bbdcb89b14bd3dd80c78a08bb /app/javascript/mastodon/features/ui/index.js
parent2e99e3cab349db6102505736e3b4b94abe776b80 (diff)
Change window resize handler to switch to/from mobile layout as soon as needed (#11656)
Diffstat (limited to 'app/javascript/mastodon/features/ui/index.js')
-rw-r--r--app/javascript/mastodon/features/ui/index.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/app/javascript/mastodon/features/ui/index.js b/app/javascript/mastodon/features/ui/index.js
index f0c3eff83..9d284c221 100644
--- a/app/javascript/mastodon/features/ui/index.js
+++ b/app/javascript/mastodon/features/ui/index.js
@@ -141,14 +141,24 @@ class SwitchingColumnsArea extends React.PureComponent {
     return location.state !== previewMediaState && location.state !== previewVideoState;
   }
 
-  handleResize = debounce(() => {
+  handleLayoutChange = debounce(() => {
     // The cached heights are no longer accurate, invalidate
     this.props.onLayoutChange();
-
-    this.setState({ mobile: isMobile(window.innerWidth) });
   }, 500, {
     trailing: true,
-  });
+  })
+
+  handleResize = () => {
+    const mobile = isMobile(window.innerWidth);
+
+    if (mobile !== this.state.mobile) {
+      this.handleLayoutChange.cancel();
+      this.props.onLayoutChange();
+      this.setState({ mobile });
+    } else {
+      this.handleLayoutChange();
+    }
+  }
 
   setRef = c => {
     this.node = c.getWrappedInstance();