Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird animation of 0-sized elements #140

Closed
RomeoDespres opened this issue Oct 30, 2020 · 5 comments
Closed

Weird animation of 0-sized elements #140

RomeoDespres opened this issue Oct 30, 2020 · 5 comments

Comments

@RomeoDespres
Copy link

Because I'm using some dynamic filtering, the elements I wrap in Flipper sometimes end up having a 0px height. They display fine when nothing moves, but when a flip animation is triggered, it seems react-flip-toolkit gives them a non-zero height only during the animation. It results in a buggy look and feel. Not sure if it's a bug or a known feature, but I'd appreciate any advice on how to avoid this!

react-flip-toolkit-0px-bug

See codesandbox here

const ListShuffler = () => {
  const [data, setData] = useState([...Array(200).keys()]);
  const shuffleList = () => setData(shuffle(data));

  // Say user has filtered to only show multiples of 50
  const n = 50;

  return (
    <Flipper flipKey={data.join("")}>
      <button onClick={shuffleList}> shuffle</button>
      <div style={{ fontFamily: "Arial", fontSize: "2.5rem" }}>
        {data.map((d) => (
          <Flipped key={d} flipId={d}>
            <div style={{ height: d % n === 0 ? 50 : 0 }}>
              {d % n === 0 ? d : null}
            </div>
          </Flipped>
        ))}
      </div>
    </Flipper>
  );
};
@aholachek
Copy link
Owner

Hi, thanks for describing this issue so clearly! The min-height of 1px that's being applied by react-flip-toolkit is meant to avoid buggy animations caused by animating to 0 height or width in Chrome, but I see that is not desirable here since the hidden elements aren't being animated. I'll update the library to skip adjusting heights and widths for non-animated flipped components, and comment here when I've published the new version, hopefully in the next day or so.

@RomeoDespres
Copy link
Author

Hi, great thanks for your quick response. Looking forward to see this solved :)

@aholachek
Copy link
Owner

I've just published a beta version (7.0.13-1) that I believe will solve this and similar problems: https://codesandbox.io/s/react-flip-toolkit-list-shuffle-example-forked-3sgqh

I need to QA it a bit more since I also included some housekeeping tasks, but I hope to publish the patch version by tomorrow.

@aholachek
Copy link
Owner

This should be fixed in 7.0.13, please let me know if you still have any issues.

@RomeoDespres
Copy link
Author

Works as a charm, thanks a lot! This library is really awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants