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

[BUG] Sharp transition during height animation #1462

Closed
present-g opened this issue Feb 19, 2022 · 5 comments
Closed

[BUG] Sharp transition during height animation #1462

present-g opened this issue Feb 19, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@present-g
Copy link

Describe the bug

I need to animate the height from 0 to 'auto', the animation scene is calculated incorrectly, and when 'auto' appears, there is a jump

IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/s/eager-silence-6cpkd0?file=/src/App.js

Steps to reproduce

Steps to reproduce the behavior:

  1. Open the page
  2. Look at the animation
  3. You can use the "Toggle" button for easy replay

The problem is only when opening ...

Expected behavior

I need a smooth, jump-free animation with lots of components inside

@present-g present-g added the bug Something isn't working label Feb 19, 2022
@mattgperry mattgperry added wontfix This will not be worked on and removed wontfix This will not be worked on labels Feb 21, 2022
@thexpand
Copy link

The reason why this happens is because of the padding on the animated element. Try eliminating the padding by adding a nested element (an inner container) and put the padding on that inner container. Then, animate the parent container - without the padding on the animated element, there shouldn't be that jumpy behavior.

@merlindru
Copy link

merlindru commented May 5, 2023

@thexpand I'm doing exactly that, but the jump still persists. Related issue: #368

@thexpand
Copy link

thexpand commented May 5, 2023

@merlindru Probably it would be best if you would provide a reproducible example with your specific use-case, e.g. in CodeSandbox.

@ervinpiol
Copy link

ervinpiol commented Aug 4, 2023

In my case I use "br" The Line Break element for the space

@dev-frid
Copy link

dev-frid commented Aug 14, 2023

Experienced something similar, the height of my container animated inconsistently regardless of padding.
Firs time animated correctly, then any subsequent height changes did not animate.

The issue was fixed by installing framer-motion@latest.

Reproduction:

<div>
      (...)
      <AnimatePresence>
        {expanded && (
          <motion.div
            initial={{ height: 0 }}
            animate={{ height: "auto" }}
            exit={{ height: 0 }}
            transition={{ duration: 0.3, ease: "easeInOut" }}
          >
            (content...)
          </motion.div>
        )}
      </AnimatePresence>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants