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

Add support for transitions when properties is changed #816

Open
Dolfik1 opened this issue Nov 17, 2020 · 2 comments
Open

Add support for transitions when properties is changed #816

Dolfik1 opened this issue Nov 17, 2020 · 2 comments
Labels
t/enhancement New feature or request
Milestone

Comments

@Dolfik1
Copy link

Dolfik1 commented Nov 17, 2020

It would be great to support animated transitions on changed properties.

The main idea is as follows: when property is changed in UpdateIncremental we should check if any transitions is attached to this property. If transition is attached to the property then we should invoke transition callback instead of modifying property value directly.

Take a look at small example:

type ITransition =
  abstract member Property: BindableProperty
  abstract member Execute: (View * obj * obj) -> unit

let transition<'a> property fn =
  { new ITransition with
      member x.Property = property
      member x.Execute(view, fromValue, toValue) =
        fn view (unbox fromValue) (unbox toValue) }
  

View.Frame(
  translationX = model.TranslationX,
  transitions = [
    transition<float> View.TranslationXProperty (fun view fromValue toValue -> 
        Animation((fun v -> view.TranslationX <- v), fromValue, toValue, Easing.CubicOut)
          .Commit(view, "MyAnimation", 16u, 200u))
  ]
)
@TimLariviere TimLariviere added the t/enhancement New feature or request label Nov 17, 2020
@TimLariviere TimLariviere added this to To do in Fabulous via automation Nov 17, 2020
@TimLariviere TimLariviere added this to To do in Fabulous for Xamarin.Forms via automation Nov 17, 2020
@TimLariviere TimLariviere added this to the vNext (2.0) milestone Nov 17, 2020
@edgarfgp
Copy link
Member

@TimLariviere Will this still be possible with v2? It seems like an excellent way to work with animations

@TimLariviere
Copy link
Member

I still don't know exactly how to incorporate animations in Fabulous. The issue with having functions inside the widgets is that we need to evaluate them all the time because we can't compare functions like we compare values.

This would require a mechanism to synchronize animations to avoid restarting an animation on each update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/enhancement New feature or request
Projects
No open projects
Development

No branches or pull requests

3 participants