]> cat aescling's git repositories - mastodon.git/commitdiff
Fix column swiping animation logic (#15301)
authorThibG <thib@sitedethib.com>
Mon, 7 Dec 2020 19:07:24 +0000 (20:07 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Dec 2020 19:07:24 +0000 (20:07 +0100)
From the start, swiping columns was highly unreliable because the logic
could change `ReactSwipeableViews`'s `animateTransitions` property
mid-swipe.

PR #11200 partially fixed this, but at the unintended cost of disabling the
swipe animation altogether.

This PR changes the logic behind `shouldAnimate` to only disable the swiping
animation at the end of a column change not initiated by `ReactSwipeableViews`.

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
app/javascript/mastodon/features/ui/components/columns_area.js

index cf02e9be7db1d07c4e9014f95cb33422568f2101..6837450eb583ecbc6491b3fc46238fcc6f235cff 100644 (file)
@@ -75,7 +75,9 @@ class ColumnsArea extends ImmutablePureComponent {
   }
 
   componentWillReceiveProps() {
-    this.setState({ shouldAnimate: false });
+    if (typeof this.pendingIndex !== 'number' && this.lastIndex !== getIndex(this.context.router.history.location.pathname)) {
+      this.setState({ shouldAnimate: false });
+    }
   }
 
   componentDidMount() {