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

Defer animation on list items until scrolled into view #131

Open
harkairt opened this issue Feb 25, 2024 · 2 comments
Open

Defer animation on list items until scrolled into view #131

harkairt opened this issue Feb 25, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@harkairt
Copy link

Similar to https://pub.dev/packages/flutter_staggered_animations I would like to be able to only animate a list's items once they appear.
Regardless of scrolling, or items changing, they should only animate for the first time.

@gskinner gskinner self-assigned this Aug 27, 2024
@gskinner gskinner added enhancement New feature or request good first issue Good for newcomers labels Aug 27, 2024
@gskinner
Copy link
Owner

Sorry for the delayed response on this.

Interesting! I'll have to look at how they made that work. Worst case, I anticipate it would be pretty easy for the author of flutter_staggered_animations to create an animation type that would accept any flutter_animate instance.

Keeping open and will look into it when time permits. Feel free to take a stab at it in the meantime.

@gskinner gskinner changed the title Add an AnimationLimiter kinda feature. Defer animation on list items until scrolled into view Sep 21, 2024
@gskinner
Copy link
Owner

gskinner commented Sep 21, 2024

Okay, I've been giving this a bunch of thought, and have the start of a flexible API in mind that I'm fairly sure can be implemented:

foo.animate(hiddenBehavior: myBehavior);

HiddenBehavior(behavior, visibleFraction=0.5, resetOnHide=false, keepAlive=true)

// behaviors:
HiddenBehavior.PLAY // play immediately on creation
HiddenBehavior.SKIP // skip to end if initially hidden
HiddenBehavior.PAUSE // remain paused at beginning if initially hidden
HiddenBehavior.WAIT // pause until visible

This would facilitate all of the behaviors I can think of:

  • current behavior (play on creation)
  • only play visible items, new items scroll in already at the end (or start) of their animation
  • play each item only when it first scrolls in
  • play every time it scrolls back in

Feedback is very welcome. I'm not 100% sure I love the naming of HiddenBehavior, but I think it's a bit more semantically intuitive than VisibilityBehavior (which is perhaps the more expected choice).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants