]> cat aescling's git repositories - mastodon.git/commitdiff
Fix column swiping (#4211)
authorunarist <m.unarist@gmail.com>
Sat, 15 Jul 2017 15:25:04 +0000 (00:25 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 15 Jul 2017 15:25:04 +0000 (17:25 +0200)
This fixes broken behavior and enable animation only on swiping.

app/javascript/mastodon/features/ui/components/columns_area.js

index ae3f9261b8cd9bc5ca0f0a5d7d3ee7b73084d094..515c377b9d4e430c7c06b71a42a23706f18cad49 100644 (file)
@@ -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 ? (