flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.62k stars 455 forks source link

Explicit animations with fine control: chain, cancel, reverse, pause #175

Open mikaelho opened 2 years ago

mikaelho commented 2 years ago

Once you have any animations, you typically run into the following use cases, in decreasing order of importance (my opinion):

  1. Run several animations in parallel

    I assume this is the base case and will be supported by default

  2. Chaining animations, i.e. start another as soon as the first one finishes (maybe with a delay)

    Could be supported with an event, but with the potential for network delay, perfect animations could probably not rely on that.

  3. Canceling an animation, e.g. when user clicks a button

    Python API would need a reference to the running animation.

  4. Running the same animation back and forth

  5. Pausing an animation with an option to continue (needs a reference, again)

FeodorFitsner commented 2 years ago

Yes, this is called in Flutter terms "explicit" animations: https://www.youtube.com/watch?v=GXIJJkq_H8g What is currently implemented in Flet (and should be documented) are "implicit" animations.

Cancelling, pausing, back/forth are all responsibilities of AnimationController which I was planning to expose in Flet API.

mikaelho commented 2 years ago

Thanks, good to hear. Looks like AnimationController has a addStatusListener that can be used to create events to Python, e.g. when the animation ends.