about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/ui/components/columns_area.js
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-07-16 00:25:04 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-07-15 17:25:04 +0200
commit695439775eacea081c7257aabab39d0ec6b492dc (patch)
treeb5c6bffe123e9cdf0e2a8443f0643626ccc51948 /app/javascript/mastodon/features/ui/components/columns_area.js
parent05cd37097c134d559550adca6cd17cf7578be94b (diff)
Fix column swiping (#4211)
This fixes broken behavior and enable animation only on swiping.
Diffstat (limited to 'app/javascript/mastodon/features/ui/components/columns_area.js')
-rw-r--r--app/javascript/mastodon/features/ui/components/columns_area.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/javascript/mastodon/features/ui/components/columns_area.js b/app/javascript/mastodon/features/ui/components/columns_area.js
index ae3f9261b..515c377b9 100644
--- a/app/javascript/mastodon/features/ui/components/columns_area.js
+++ b/app/javascript/mastodon/features/ui/components/columns_area.js
@@ -33,8 +33,22 @@ export default class ColumnsArea extends ImmutablePureComponent {
     children: PropTypes.node,
   };
 
+  state = {
+    shouldAnimate: false,
+  }
+
+  componentWillReceiveProps() {
+    this.setState({ shouldAnimate: false });
+  }
+
+  componentDidMount() {
+    this.lastIndex = getIndex(this.context.router.history.location.pathname);
+    this.setState({ shouldAnimate: true });
+  }
+
   componentDidUpdate() {
     this.lastIndex = getIndex(this.context.router.history.location.pathname);
+    this.setState({ shouldAnimate: true });
   }
 
   handleSwipe = (index) => {
@@ -74,9 +88,10 @@ export default class ColumnsArea extends ImmutablePureComponent {
 
   render () {
     const { columns, children, singleColumn } = this.props;
+    const { shouldAnimate } = this.state;
 
     const columnIndex = getIndex(this.context.router.history.location.pathname);
-    const shouldAnimate = Math.abs(this.lastIndex - columnIndex) === 1;
+    this.pendingIndex = null;
 
     if (singleColumn) {
       return columnIndex !== -1 ? (