InteractionTrackerInertiaMotion InteractionTrackerInertiaMotion InteractionTrackerInertiaMotion InteractionTrackerInertiaMotion Class


An ExpressionAnimation that defines motion of InteractionTracker during its inertia state.

The InteractionTrackerMotion class contains two ExpressionAnimation s 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 : sealed class InteractionTrackerInertiaMotion : InteractionTrackerInertiaModifier
struct winrt::Windows::UI::Composition::Interactions::InteractionTrackerInertiaMotion : InteractionTrackerInertiaModifier
public sealed class InteractionTrackerInertiaMotion : InteractionTrackerInertiaModifier
Public NotInheritable Class InteractionTrackerInertiaMotion Inherits InteractionTrackerInertiaModifier

Windows 10 requirements

Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)


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


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.


Comment Comment Comment Comment

A string to associate with the CompositionObject.

(Inherited from CompositionObject)
Compositor Compositor Compositor Compositor

The Compositor used to create this CompositionObject.

(Inherited from CompositionObject)
Condition Condition Condition 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 Dispatcher Dispatcher Dispatcher

The dispatcher for the CompositionObject.

(Inherited from CompositionObject)
DispatcherQueue DispatcherQueue DispatcherQueue DispatcherQueue

Gets the DispatcherQueue for the CompostionObject.

(Inherited from CompositionObject)
ImplicitAnimations ImplicitAnimations ImplicitAnimations ImplicitAnimations

The collection of implicit animations attached to this object.

(Inherited from CompositionObject)
Motion Motion Motion 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 Properties Properties Properties

The collection of properties associated with the CompositionObject.

(Inherited from CompositionObject)


Close Close Close Close

Closes the CompositionObject and releases system resources.

(Inherited from CompositionObject)
Create(Compositor) Create(Compositor) Create(Compositor) Create(Compositor)

Creates an instance of InteractionTrackerInertiaMotion.

PopulatePropertyInfo(String,AnimationPropertyInfo) PopulatePropertyInfo(String,AnimationPropertyInfo) PopulatePropertyInfo(String,AnimationPropertyInfo) PopulatePropertyInfo(String,AnimationPropertyInfo)

Defines a property that can be animated.

(Inherited from CompositionObject)
StartAnimation(String,CompositionAnimation) StartAnimation(String,CompositionAnimation) StartAnimation(String,CompositionAnimation) StartAnimation(String,CompositionAnimation)

Connects an animation with the specified property of the object and starts the animation.

(Inherited from CompositionObject)
StartAnimationGroup(ICompositionAnimationBase) StartAnimationGroup(ICompositionAnimationBase) StartAnimationGroup(ICompositionAnimationBase) 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)
StartAnimationGroupWithIAnimationObject(IAnimationObject,ICompositionAnimationBase) StartAnimationGroupWithIAnimationObject(IAnimationObject,ICompositionAnimationBase) StartAnimationGroupWithIAnimationObject(IAnimationObject,ICompositionAnimationBase) StartAnimationGroupWithIAnimationObject(IAnimationObject,ICompositionAnimationBase)

Starts an animation group on the specified target.

(Inherited from CompositionObject)
StartAnimationWithIAnimationObject(IAnimationObject,String,CompositionAnimation) StartAnimationWithIAnimationObject(IAnimationObject,String,CompositionAnimation) StartAnimationWithIAnimationObject(IAnimationObject,String,CompositionAnimation) StartAnimationWithIAnimationObject(IAnimationObject,String,CompositionAnimation)

Connects an animation with the specified property of the target object and starts the animation.

(Inherited from CompositionObject)
StopAnimation(String) StopAnimation(String) StopAnimation(String) StopAnimation(String)

Disconnects an animation from the specified property and stops the animation.

(Inherited from CompositionObject)
StopAnimationGroup(ICompositionAnimationBase) StopAnimationGroup(ICompositionAnimationBase) StopAnimationGroup(ICompositionAnimationBase) StopAnimationGroup(ICompositionAnimationBase)

Stops an animation group.

(Inherited from CompositionObject)
TryGetAnimationController(String) TryGetAnimationController(String) TryGetAnimationController(String) TryGetAnimationController(String)

Returns an AnimationController for the animation running on the specified property.

(Inherited from CompositionObject)

See also