This interface allows custom classes to implement simple animations. Anything numeric can be animated using this interface and the AnimationKit.ValueTask task.
Sub AnimationStep (Identifier As Text, Value As Double)
This method is fired as often as necessary to run the animation, providing both the identifier and current value.
The following class is a Label subclass which accepts an integer value and animates counting up/down to the new value. A reference to the last task is retained so the animation can be interrupted and changed to a new value.
Class CountingLabel Inherits Label
Public Sub Add (Amount As Integer)
Self.Value = Self.Value + Amount
Public Sub AnimationStep (Identifier As Text, Value As Double)
// Part of the AnimationKit.ValueAnimator interface.
Select Case Identifier
Self.Text = Str(Round(Value), "-0")
Public Sub Subtract (Amount As Integer)
Self.Value = Self.Value - Amount
Public Function Value () As Integer
Public Sub Value (Assigns NewValue As Integer)
If Task <> Nil And Not (Task.Completed Or Task.Cancelled) Then
Task = Nil
Task = New AnimationKit.ValueTask(Self, "Text", Self.Value, Value)
Task.DurationInSeconds = 1
Task.Curve = AnimationKit.Curve.CreateEaseOut
Private Property Task As AnimationKit.ValueTask