Skip to content

overflow: auto displays scrollbars during animation #16

Closed

Description

@ty-bt

windows chrome 102.0.5005.63

https://codesandbox.io/s/naughty-butterfly-ze3mcu?file=/src/App.js

When overflow is auto, the scroll bar will flicker during animation
Subsequent animation flickers after scrolling scrollbar manually
333

Activity

  1. justin-schroeder commented on May 27, 2022

    @justin-schroeder
    Member

    Not sure there is a good solution to this other than setting your styles appropriately. I dont think we can make any reliable determination of what the users desired styles are here. For example, we could put overflow: none durring the animation, but that would make the parent's scrollbars pop on/off during animation when there should be a scroll bar. Open to suggestions though.

  2. changed the title [-]css overflow auto animation exception[/-] [+]`overflow: auto` displays scrollbars during animation[/+] on May 27, 2022
  3. ty-bt commented on May 30, 2022

    @ty-bt
    Author

    @justin-schroeder And the first animation after moving the scroll bar will be abnormal

  4. Daneng66 commented on Jun 17, 2023

    @Daneng66

    @ty-bt Did you figure out a solution for this?

  5. glekner commented on Sep 24, 2024

    @glekner

    Not sure there is a good solution to this other than setting your styles appropriately. I dont think we can make any reliable determination of what the users desired styles are here. For example, we could put overflow: none durring the animation, but that would make the parent's scrollbars pop on/off during animation when there should be a scroll bar. Open to suggestions though.

    @justin-schroeder why not do the following:

    1. before starting the animation, we determine if the container has overflowing content or not for each axis (e.g. is p.scrollHeight > p.offsetHeight)
    2. only if there is no overflowing content, we can safely add overflow: hidden until the animation finishes.
  6. justin-schroeder commented on Nov 22, 2026

    @justin-schroeder
    Member

    Closing with a docs tip in #258 📜 — AutoAnimate can't safely guess the overflow styles you want, but two CSS lines fix it on the container: scrollbar-gutter: stable (reserves the scrollbar's space so content doesn't jump while sizes change mid-animation) and overflow-x: clip if you don't need horizontal scrolling. If you still see weirdness with those, a repro and we'll dig in!

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