Class TransitionBehavior<TValue>
Definition
Namespace: StardewUI.Framework.Behaviors
Assembly: StardewUI.dll
Behavior that applies gradual transitions (AKA tweens) to view properties.
Type Parameters
TValue
Value type for the transitioned property.
Inheritance
Object ⇦ ViewBehavior<TView, TData> ⇦ TransitionBehavior<TValue>
Members
Constructors
Name | Description |
---|---|
TransitionBehavior<TValue>(string, Lerp<TValue>) | Behavior that applies gradual transitions (AKA tweens) to view properties. |
Properties
Name | Description |
---|---|
Data | The assigned or bound data. (Inherited from ViewBehavior<TView, TData>) |
View | The currently-attached view. (Inherited from ViewBehavior<TView, TData>) |
ViewState | State overrides for the View. (Inherited from ViewBehavior<TView, TData>) |
Methods
Name | Description |
---|---|
CanUpdate() | Checks whether the behavior is allowed to Update(TimeSpan). (Inherited from ViewBehavior<TView, TData>) |
Dispose() | (Inherited from ViewBehavior<TView, TData>) |
Initialize(BehaviorTarget) | Initializes the target (view, state overrides, etc.) for the behavior. (Inherited from ViewBehavior<TView, TData>) |
OnAttached() | Runs after the behavior is attached to a target. (Overrides ViewBehavior<TView, TData>.OnAttached()) |
OnDetached(IView) | Runs when the behavior is detached from a target. (Overrides ViewBehavior<TView, TData>.OnDetached(IView)) |
OnDispose() | Runs when the behavior is being disposed. (Inherited from ViewBehavior<TView, TData>) |
OnNewData(TData) | (Inherited from ViewBehavior<TView, TData>) |
PreUpdate(TimeSpan) | Runs on every update tick, before any bindings or views update. (Overrides ViewBehavior<TView, TData>.PreUpdate(TimeSpan)) |
Update(TimeSpan) | Runs on every update tick. (Overrides ViewBehavior<TView, TData>.Update(TimeSpan)) |
Details
Constructors
TransitionBehavior<TValue>(string, Lerp<TValue>)
Behavior that applies gradual transitions (AKA tweens) to view properties.
Parameters
propertyName
string
Name of the overridden property.
lerp
Lerp<TValue>
Interpolation function for the transitioned property type.
Methods
OnAttached()
Runs after the behavior is attached to a target.
Remarks
Setup code should go in this method to ensure that the values of View and ViewState are actually assigned. If code runs in the behavior's constructor, these are not guaranteed to be populated.
OnDetached(IView)
Runs when the behavior is detached from a target.
Parameters
view
IView
The view that was previously attached.
Remarks
Behaviors may receive new views as part of a "rebind", if the old view is destroyed and recreated, for example as the result of a conditional binding changing states.
OnDetached
is always immediately followed by OnAttached(). A behavior cannot remain in a detached state; however, overriding this method gives behaviors the opportunity to clean up state from the old view (e.g. remove event handlers) before the new one is attached.
Also runs when the behavior is disposed, so detach logic does not need to be duplicated in OnDispose().
PreUpdate(TimeSpan)
Runs on every update tick, before any bindings or views update.
Parameters
elapsed
TimeSpan
Remarks
Typically used to read information about the underlying view as it existed at the beginning of the frame, e.g. to handle a transition.
Update(TimeSpan)
Runs on every update tick.
Parameters
elapsed
TimeSpan
Time elapsed since the last update.