]> cat aescling's git repositories - mastodon.git/commitdiff
error fixed (when loading pages in single column mode.) (#4746)
authorMitarashiDango <MitarashiDango@users.noreply.github.com>
Wed, 30 Aug 2017 15:30:25 +0000 (00:30 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 30 Aug 2017 15:30:25 +0000 (17:30 +0200)
app/javascript/mastodon/features/ui/components/columns_area.js

index 2dd71dbc61fa0ef5b194b58e45e7105055ad5fb2..a4c60d9683f9aee979cabf7f2eec682092ec3d3c 100644 (file)
@@ -48,18 +48,31 @@ export default class ColumnsArea extends ImmutablePureComponent {
   }
 
   componentDidMount() {
-    this.node.addEventListener('wheel', this.handleWheel,  detectPassiveEvents ? { passive: true } : false);
+    if (!this.props.singleColumn) {
+      this.node.addEventListener('wheel', this.handleWheel,  detectPassiveEvents ? { passive: true } : false);
+    }
     this.lastIndex = getIndex(this.context.router.history.location.pathname);
     this.setState({ shouldAnimate: true });
   }
 
-  componentDidUpdate() {
+  componentWillUpdate(nextProps) {
+    if (this.props.singleColumn !== nextProps.singleColumn && nextProps.singleColumn) {
+      this.node.removeEventListener('wheel', this.handleWheel);
+    }
+  }
+
+  componentDidUpdate(prevProps) {
+    if (this.props.singleColumn !== prevProps.singleColumn && !this.props.singleColumn) {
+      this.node.addEventListener('wheel', this.handleWheel,  detectPassiveEvents ? { passive: true } : false);
+    }
     this.lastIndex = getIndex(this.context.router.history.location.pathname);
     this.setState({ shouldAnimate: true });
   }
 
   componentWillUnmount () {
-    this.node.removeEventListener('wheel', this.handleWheel);
+    if (!this.props.singleColumn) {
+      this.node.removeEventListener('wheel', this.handleWheel);
+    }
   }
 
   handleChildrenContentChange() {