InteractionTrackerInertiaMotion Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An ExpressionAnimation that defines motion of InteractionTracker during its inertia state.
The InteractionTrackerMotion class contains two ExpressionAnimations representing a second derivative equation of position InteractionTracker will use to define the motion from the start to end of inertia when a particular condition is met. The InteractionTrackerMotion class is defined as two parts: The conditional statement to define when the motion will take place and the equation that describes the motion for how InteractionTracker will reach its final resting position. Utilize the InteractionTrackerInertiaMotion class when you need to define a customized motion (such as a spring motion) for InteractionTracker to use when in its inertia state.
public ref class InteractionTrackerInertiaMotion sealed : InteractionTrackerInertiaModifier
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class InteractionTrackerInertiaMotion final : InteractionTrackerInertiaModifier
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class InteractionTrackerInertiaMotion : InteractionTrackerInertiaModifier
Public NotInheritable Class InteractionTrackerInertiaMotion
Inherits InteractionTrackerInertiaModifier
- Inheritance
-
Object Platform::Object IInspectable CompositionObject InteractionTrackerInertiaModifier InteractionTrackerInertiaMotion
- Attributes
Windows requirements
Device family |
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v3.0)
|
Examples
void CustomSpringInertiaMotion(float dampingCoefficient, float springStiffnessCoefficient)
{
//
// Set up our inertia modifiers to use our custom motion
//
InteractionTrackerInertiaMotion[] modifiers =
new InteractionTrackerInertiaMotion[1];
var modifier1 = InteractionTrackerInertiaMotion.Create(_compositor);
/*
We create a custom spring motion for when the InteractionTracker passes the
maximum boundary.
When we hit the boundary, the amount of oscillation is determined by the distance to the far end point, the spring stiffness and damping rate.
*/
// Define the condition that the spring motion gets applied – when we pass the
// maximum boundary
modifier1.Condition = _compositor.CreateExpressionAnimation(
"this.Target.NaturalRestingPosition.X > this.Target.MaxPosition.X");
// Define the second derivative equation as a custom spring force motion
// Equation = kx–cv where (k is spring constant, c is damping, x is displacement)
modifier1.Motion = _compositor.CreateExpressionAnimation(
"(-springStiffnessCoefficient * (this.Target.Position.X – this.Target.MaxPosition.X)) + " +
"(-dampingCoefficient * target.PositionVelocityInPixelsPerSecond.X");
modifier1.Motion.SetScalarParameter("springStiffnessCoefficient", springStiffnessCoefficient);
modifier1.Motion.SetScalarParameter("dampingCoefficient", dampingCoefficient);
modifiers[0] = modifier1;
// Attach InertiaModifiers to the Y position component of InteractionTracker
_tracker.ConfigurePositionYInertiaModifiers(modifiers);
}
Remarks
When building out the ExpressionAnimation for the motion component of InteractionTrackerInertiaMotion, the expression is described as a second derivative equation. For example, In the code snippet above, we utilize the basic equation for Spring Force motion with damping.
When attaching the InteractionTrackerInertiaMotion modifier to the InteractionTracker, you configure it to either the X/Y Position or Scale.
The ExpressionAnimation defining the condition property only gets evaluated once when InteractionTracker enters Inertia (aka when the interaction completes such as finger released). If the condition evaluates to true, the InertiaMotion Expression gets evaluated every frame for the remainder of Inertia, even if the condition expression technically is no longer true.
InteractionTrackerInertiaMotion modifiers change the equation InteractionTracker uses to calculate its position. Thus, the final resting position is determined by the nature of the equation itself. If you need InteractionTracker to stop at a specific location, utilize the InteractionTrackerInertiaRestingValue modifier.
Properties
Comment |
A string to associate with the CompositionObject. (Inherited from CompositionObject) |
Compositor |
The Compositor used to create this CompositionObject. (Inherited from CompositionObject) |
Condition |
An ExpressionAnimation describing when the modifier should be applied. The Condition property is an ExpressionAnimation that defines when the specified motion equation is utilized by InteractionTracker during Inertia. This expression gets evaluated once after the interaction occurs and must resolve to a type Bool, otherwise an error will be thrown when the condition is evaluated. See the ExpressionAnimation class page for more details on building expressions. |
Dispatcher |
The dispatcher for the CompositionObject. (Inherited from CompositionObject) |
DispatcherQueue |
Gets the DispatcherQueue for the CompostionObject. (Inherited from CompositionObject) |
ImplicitAnimations |
The collection of implicit animations attached to this object. (Inherited from CompositionObject) |
Motion |
An ExpressionAnimation describing the modified motion for InteractionTracker if the expression in the Condition property is true. The Motion property is an ExpressionAnimation that describes the motion InteractionTracker will utilize during Inertia when the corresponding condition is met. The expression will be evaluated every frame while InteractionTracker is in Inertia and must resolve to a type Float, otherwise an error will be thrown when the equation is evaluated. See the ExpressionAnimation class page for more details on building expressions. |
Properties |
The collection of properties associated with the CompositionObject. (Inherited from CompositionObject) |
Methods
Close() |
Closes the CompositionObject and releases system resources. (Inherited from CompositionObject) |
ConnectAnimation(String, CompositionAnimation) |
Connects and animation. (Inherited from CompositionObject) |
Create(Compositor) |
Creates an instance of InteractionTrackerInertiaMotion. |
DisconnectAnimation(String) |
Disconnects an animation. (Inherited from CompositionObject) |
Dispose() |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from CompositionObject) |
PopulatePropertyInfo(String, AnimationPropertyInfo) |
Defines a property that can be animated. (Inherited from CompositionObject) |
StartAnimation(String, CompositionAnimation, AnimationController) |
Connects an animation with the specified property of the object and starts the animation. (Inherited from CompositionObject) |
StartAnimation(String, CompositionAnimation) |
Connects an animation with the specified property of the object and starts the animation. (Inherited from CompositionObject) |
StartAnimationGroup(ICompositionAnimationBase) |
Starts an animation group. The StartAnimationGroup method on CompositionObject lets you start CompositionAnimationGroup. All the animations in the group will be started at the same time on the object. (Inherited from CompositionObject) |
StopAnimation(String) |
Disconnects an animation from the specified property and stops the animation. (Inherited from CompositionObject) |
StopAnimationGroup(ICompositionAnimationBase) |
Stops an animation group. (Inherited from CompositionObject) |
TryGetAnimationController(String) |
Returns an AnimationController for the animation running on the specified property. (Inherited from CompositionObject) |