question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

leaveAnimation is strange with bottom aligned lists

See original GitHub issue

Hi, thank you very much for your lib. react-flip-move works really well for me in most cases where I have a normal list and every new item is added to the end of the list.

------container------
  ---list---
    -item1-
    -item2-


------container------

However I want to use this for notifications which animate from bottom to top. In this case my container is position: 'fixed' and bottom: 0. It looks like this:

------container------


    -item1-
    -item2-
  ---list---
------container------

The enter animation works fine, but the leave animation is strange. When I remove -item1- it will be displayed behind -item2-:

------container------



    -item2- (-item1- onLeave)
  ---list---
------container------

I thought that would be because the container immediately changes its height to the height of -item2- (because it is the only remaining item), but setting maintainContainerHeight to true results in this:

------container------


    -item2- (moves up for a short moment)

  ---list---
------container------

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
donaldpipowitchcommented, Jan 30, 2017

Just tested it. Works great. Thanks.

1reaction
joshwcomeaucommented, Jan 27, 2017

Hi @donaldpipowitch,

Thanks for the kind words 😃

Gonna talk through this problem, mainly for my own benefit, but also for any contributors who want to help tackle this issue.

So yeah, the problem has to do with the fact that we’re using the element’s relative offset from the top of the parent. In other words:

----------container------------
                |
              20px
                |
           ----item----

When items are set to leave, I remove them from the DOM flow by setting position: absolute and top: 20px. Because it’s removed from the DOM flow, though, the parent container shrinks, and now it’s offset 20px from the new top of the container.

maintainContainerHeight solves this problem but introduces a new one: all of the other items are counting on the container to shrink. Without that shrinkage, there’s no distinction between this and a regular, top-aligned list; items will move up to fill the space, not down.

I have an idea for how to fix it, and it might also tackle some other issues I’ve had with display: flex. Essentially I would keep track of the absolute position of the parent container. When an animation is triggered, I’d check to see where the new top/bottom/left/right of the parent container is, and use that to determine which “side” to be relative from.

So in this case, the top has changed but the bottom has remained constant, so I would animate all the children relative to the bottom of the container, not the top.

Will spend some time on this today but no promises on a quick fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I prevent a bottom-aligned View from jumping during ...
I set the container to animate changes using: LayoutTransition transition = new LayoutTransition(); transition.enableTransitionType( ...
Read more >
How to bottom align text in After Effects - YouTube
FREE browser extension to grow your YouTube channel:https://www.tubebuddy.com/davidlindgren1989If you want a text to expand upwards instead ...
Read more >
Align "bottom" of marginpar with "last" line of paragraph - TeX
If I typeset the following, (obviously) the top of the marginpar aligns with the last line of the paragraph, which looks ugly. \documentclass{ ......
Read more >
Enter/Exit animations · Issue #18 · joshwcomeau/react-flip-move ...
One idea for animations might be to have new items enter from eg above the browser window, and departing items exit via eg...
Read more >
Alignment Guides in SwiftUI
Alignment guides are a powerful tool that helps layout our SwiftUI views. They often save us from having to use more complex options...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found