InteractionTrackerInertiaMotion InteractionTrackerInertiaMotion InteractionTrackerInertiaMotion InteractionTrackerInertiaMotion Class

Definition

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, IInteractionTrackerInertiaMotionpublic sealed class InteractionTrackerInertiaMotion : InteractionTrackerInertiaModifier, IInteractionTrackerInertiaMotionPublic NotInheritable Class InteractionTrackerInertiaMotion Inherits InteractionTrackerInertiaModifier Implements IInteractionTrackerInertiaMotion// This API is not available in Javascript.
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Inherited Members

Inherited methods

Inherited properties

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

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.

public : ExpressionAnimation Condition { get; set; }public ExpressionAnimation Condition { get; set; }Public ReadWrite Property Condition As ExpressionAnimation// This API is not available in Javascript.

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.

public : ExpressionAnimation Motion { get; set; }public ExpressionAnimation Motion { get; set; }Public ReadWrite Property Motion As ExpressionAnimation// This API is not available in Javascript.
Value
ExpressionAnimation ExpressionAnimation ExpressionAnimation ExpressionAnimation

An ExpressionAnimation describing the modified motion for InteractionTracker if the expression in the Condition property is true.

Methods

Create(Compositor) Create(Compositor) Create(Compositor) Create(Compositor)

Creates an instance of InteractionTrackerInertiaMotion.

public : static InteractionTrackerInertiaMotion Create(Compositor compositor)public static InteractionTrackerInertiaMotion Create(Compositor compositor)Public Static Function Create(compositor As Compositor) As InteractionTrackerInertiaMotion// This API is not available in Javascript.
Parameters
compositor
Compositor Compositor Compositor Compositor

The compositor to use when creating the InteractionTrackerInertiaMotion object.

Returns

See Also