Skip to content

[BUG] AnimatePresence height animation with padding doesn't work #368

@snowl

Description

@snowl

1. Read the FAQs 👇

2. Describe the bug

When using AnimatePresence with some padding in the div that you are animating w/ height animation, the height calculation breaks and only animates the height to the (internal height - padding), both in and out.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/s/framer-motion-animatepresence-padding-issue-zqxrk?fontsize=14

If you remove the padding: within the div css, you can see how much more smooth the animation is.

4. Steps to reproduce

Animate height on a div that has padding.

5. Expected behavior

Height should go from 0 to the height calculated by the browser for "auto".

6. Video or screenshots

Here's a gif of how it looks in my application: https://gfycat.com/weirdachingdogwoodclubgall

You can see the div underneath "snaps" because of all the height that still exists due to the padding.

7. Environment details

Tested in chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions