Skip to content

Add support for transitions when properties is changed #816

@Dolfik1

Description

@Dolfik1

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))
  ]
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions