Skip to content

Applying AutoAnimate to table rows destroys row display format #7

Closed

Description

@ThenTech

Straightforward and easy to use library so far.

I was however testing out animations on tables, sorting (rows moving) and removing filters (adding rows) work great.
But removing rows, collapses the style of them and make them weirdly float outside the table. Also the sizing of the parent during the animation looks off.

Example in this sandbox: https://codesandbox.io/s/upbeat-kapitsa-hx0mvd?file=/src/App.js

Any advice on how to handle this? (without styling plain divs to look like a table)

Activity

  1. justin-schroeder commented on May 21, 2022

    @justin-schroeder
    Member

    Great point — we might need to handle tables a bit better. We'll try to push out a fix by/on Monday.

  2. kasparsuvi1 commented on Jun 6, 2022

    @kasparsuvi1

    Is there any update on this?

  3. kasparsuvi1 commented on Jul 5, 2022

    @kasparsuvi1

    @justin-schroeder Hey, sorry for pinging once more. Have you had time to give a look at it? This seems important feature if it is possible to add.

  4. needim commented on Aug 9, 2022

    @needim

    just stumbled upon this from https://github.com/samselikoff

    sandbox: https://codesandbox.io/s/github/samselikoff/2022-08-04-animated-table?file=/pages/index.tsx
    repo: https://github.com/samselikoff/2022-08-04-animated-table

    edit: also there is a video in which he explains things: https://www.youtube.com/watch?v=IfAv4NSv-nA

    maybe we can get some tips from it and improve this library! I will dive into it tomorrow if I have some time.

  5. justin-schroeder commented on Aug 10, 2022

    @justin-schroeder
    Member

    Thanks for the suggestion. I took a look at it, and unfortunately its using some techniques that probably wont work for us, like fixed column widths.

  6. rberneder commented on Nov 11, 2022

    @rberneder

    Is there any progress on this?

  7. justin-schroeder commented on Nov 11, 2022

    @justin-schroeder
    Member

    Currently havent found a way to do this automatically. Ive done a number of tests, and the sequence of sizing/painting the browser does (for tables) is pretty wacky and – at the moment not very compatible with auto-animate. Still something Im interested in solving for though.

  8. BorisSavage commented on Mar 16, 2023

    @BorisSavage

    Got the same problem - this nice library unfortunately does not handle row removal well in grid/flex layouts. Spent a whole day trying to figure out what was wrong with my code. Turns out it's the first time it's objectively the library's issue, not mine. ¯\(ツ)/¯

  9. mjyoung commented on Dec 19, 2023

    @mjyoung

    Has anyone figured out a good workaround for this? Would love to use this with tbody tr

  10. kevinashworth commented on Feb 16, 2024

    @kevinashworth

    For table tbody tr add/remove, I'm liking the results a little more than the defaults through simplifying the animation through a custom plugin:

    const [parent] = useAutoAnimate((el, action) => {
      let keyframes;
      if (action === "add") {
        keyframes = [
          { transform: "scale(.98)", opacity: 0 },
          { transform: "scale(1)", opacity: 1 },
        ];
      }
      if (action === "remove") {
        keyframes = [
          { transform: "scale(1)", opacity: 1 },
          { transform: "scale(.98)", opacity: 0 },
        ];
      }
      if (action === "remain") {
        keyframes = [{ opacity: 0.98 }, { opacity: 1 }];
      }
      return new KeyframeEffect(el, keyframes, { duration: 250, easing: "ease-in-out" });
    });
    

    I've also added overflow-hidden to the containing div, which seems to hide the final "flash". But only sometimes.

  11. VladBrok commented on Mar 3, 2024

    @VladBrok

    For table tbody tr add/remove, I'm liking the results a little more than the defaults through simplifying the animation through a custom plugin:

    const [parent] = useAutoAnimate((el, action) => {
      let keyframes;
      if (action === "add") {
        keyframes = [
          { transform: "scale(.98)", opacity: 0 },
          { transform: "scale(1)", opacity: 1 },
        ];
      }
      if (action === "remove") {
        keyframes = [
          { transform: "scale(1)", opacity: 1 },
          { transform: "scale(.98)", opacity: 0 },
        ];
      }
      if (action === "remain") {
        keyframes = [{ opacity: 0.98 }, { opacity: 1 }];
      }
      return new KeyframeEffect(el, keyframes, { duration: 250, easing: "ease-in-out" });
    });
    

    I've also added overflow-hidden to the containing div, which seems to hide the final "flash". But only sometimes.

    @kevinashworth, thanks, your solution helped!

  12. siamahnaf commented on Aug 26, 2024

    @siamahnaf

    Animation not working properly on tbody

  13. dBianchii commented on Mar 28, 2025

    @dBianchii

    Animation not working well for me with TableBody from MUI. Works fine when reordering items. But when deleting them, it looks funky and bad

  14. willashley23 commented on Mar 29, 2025

    @willashley23

    Same story with table bodies and ShadCN's Table component. Very janky on entering but especially on exiting.

  15. ShivamJoker commented on Oct 28, 2025

    @ShivamJoker

    Facing the same issue with Table.

           <table className="border border-dashed p-4 my-2 border-separate border-spacing-4">
              <thead>
                <tr>
                  <th>Drink</th>
                  <th>Takes</th>
                  <th>Time</th>
                  <th>Status</th>
                </tr>
              </thead>
              <tbody ref={parent}>
                {queue?.map((item) => (
                  <tr key={item.orderedAt.toISOString()}>
                    <td>{item.name}</td>
                    <td>{item.duration}s</td>
                    <td>{item.orderedAt.toLocaleTimeString()}</td>
                    <td className="capitalize">{item.status}</td>
                  </tr>
                ))}
              </tbody>
            </table>
  16. justin-schroeder commented on Nov 22, 2026

    @justin-schroeder
    Member

    Finally fixed in #260 🍽️ — removed <tr>s now keep their cell layout while they fade out (no more collapsing cells or rows floating outside the table), including border-spacing, border-collapse, header rows and scaled tables, in Chrome, Firefox and Safari. MUI / shadcn TableBody render plain <tr>s, so they should benefit too — shout if not. Ships in the next release — thanks everyone for the patience (and the repros)!

  17. justin-schroeder commented on Nov 23, 2026

    @justin-schroeder
    Member

    Out now in @formkit/auto-animate@0.11.0 🚢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions