Skip to content

Add some way to specify whether scroll_to_rect etc.. should be animated #4295

@lucasmerlin

Description

@lucasmerlin

Egui should allow specifying whether scrolling in a ScrollArea should be animated (and also allow changing the animation duration, although that is not important for my problem)

Is your feature request related to a problem? Please describe.

After #4119 scrolling to a certain offset is always animated, this breaks egui_virtual_list, which relied on scroll_to_rect to instantly update the scroll position. This is necessary when the user scrolls up in a infinite scroll list that loads at the top and new content is added at the top (the scroll position is offset by the height of the new content). If the scroll is animated here, the list unexpectedly jumps for the user.

Describe the solution you'd like
Maybe add an additional parameter to the scroll functions, a bool or maybe a enum like

enum ScrollAnimation {
    None,
    Default,
    Custom(Duration, Easing),
}

I also saw a TODO comment saying this should be made configurable via Style, but that would cause an issue for my crate, if I set the scroll animation duration to zero the user might override this at a later point causing the infinite scroll to break. The user could work around this by only updating the style if scroll_to_* is actually called but this wouldn't be ideal.
Maybe there could be e.g. a scroll_to_rect() with the current signature which uses the value from Style and an additional funciton like scroll_to_rect_animated() that takes the enum from above as an additional argument.

Describe alternatives you've considered
My problem could also be solved by #2783, which would allow me to use scroll_with_delta, which curiously doesn't seem to have an animation (I'm not sure if this is intentional). But due to #2783, scroll_with_delta doesn't work reliably for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions