AnimationKit.ValueAnimator

This interface allows custom classes to implement simple animations. Anything numeric can be animated using this interface and the AnimationKit.ValueTask task.

Interface Methods

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.

Example Class

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
End Sub

Public Sub AnimationStep (Identifier As Text, Value As Double)
// Part of the AnimationKit.ValueAnimator interface.

Select Case Identifier
Case "Text"
Self.Text = Str(Round(Value), "-0")
End Select
End Sub

Public Sub Subtract (Amount As Integer)
Self.Value = Self.Value - Amount
End Sub

Public Function Value () As Integer
Return Val(Self.Text)
End Function

Public Sub Value (Assigns NewValue As Integer)
If Task <> Nil And Not (Task.Completed Or Task.Cancelled) Then
Task.Cancel
Task = Nil
End If

Task = New AnimationKit.ValueTask(Self, "Text", Self.Value, Value)
Task.DurationInSeconds = 1
Task.Curve = AnimationKit.Curve.CreateEaseOut
Task.Run
End Sub

Private Property Task As AnimationKit.ValueTask
End Class

See Also

AnimationKit.ValueTask