Share via


InteractionTrackerInertiaMotion 类

定义

一个 ExpressionAnimation,用于定义 InteractionTracker 在其惯性状态期间的运动。

InteractionTrackerMotion 类包含两个 ExpressionAnimation,表示 InteractionTracker 将在满足特定条件时用于定义从惯性开始到结束的运动的第二个位置导数公式。 InteractionTrackerMotion 类定义为两个部分:用于定义何时发生运动的条件语句和描述 InteractionTracker 如何到达其最终静态位置的运动的公式。 当需要定义自定义运动 ((例如弹簧运动) ,当 InteractionTracker 处于惯性状态时,请使用 InteractionTrackerInertiaMotion 类。

public ref class InteractionTrackerInertiaMotion sealed : InteractionTrackerInertiaModifier
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.LiftedContract, 65536)]
/// [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.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65536)]
class InteractionTrackerInertiaMotion final : InteractionTrackerInertiaModifier
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.LiftedContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class InteractionTrackerInertiaMotion : InteractionTrackerInertiaModifier
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65536)]
public sealed class InteractionTrackerInertiaMotion : InteractionTrackerInertiaModifier
Public NotInheritable Class InteractionTrackerInertiaMotion
Inherits InteractionTrackerInertiaModifier
继承
Object Platform::Object IInspectable CompositionObject InteractionTrackerInertiaModifier InteractionTrackerInertiaMotion
属性

示例

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);
}

注解

为 InteractionTrackerInertiaMotion 的运动组件生成 ExpressionAnimation 时,表达式描述为第二个导数公式。 例如,在上面的代码片段中,我们使用带阻尼的 Spring Force 运动的基本公式。

将 InteractionTrackerInertiaMotion 修饰符附加到 InteractionTracker 时,可以将其配置为 X/Y 位置或缩放。

定义条件属性的 ExpressionAnimation 仅在 InteractionTracker 进入惯性 (即交互完成(例如手指释放) )时计算一次。 如果条件的计算结果为 true,则即使条件表达式在技术上不再为 true,惯性表达式的剩余部分也会计算每个帧。

InteractionTrackerInertiaMotion 修饰符更改 InteractionTracker 用于计算其位置的公式。 因此,最终的静态位置由公式本身的性质决定。 如果需要 InteractionTracker 停止在特定位置,请使用 InteractionTrackerInertiaRestingValue 修饰符。

属性

Comment

要与 CompositionObject 关联的字符串。

(继承自 CompositionObject)
Compositor

用于创建此 CompositionObject 的 Compositor

(继承自 CompositionObject)
Condition

描述何时应应用修饰符的 ExpressionAnimation

Condition 属性是 ExpressionAnimation ,用于定义 交互跟踪器 在惯性期间何时使用指定的运动公式。 此表达式在交互发生后计算一次,并且必须解析为 Bool 类型,否则在计算条件时将引发错误。 有关生成表达式的更多详细信息,请参阅 ExpressionAnimation 类页。

DispatcherQueue

获取 CompositionObject 的 DispatcherQueue。

(继承自 CompositionObject)
ImplicitAnimations

附加到此对象的隐式动画集合。

(继承自 CompositionObject)
Motion

如果 Condition 属性中的表达式为 true,则描述 InteractionTracker 的修改运动的 ExpressionAnimation

Motion 属性是一个 ExpressionAnimation ,用于描述在满足相应条件时 ,交互跟踪器 将在惯性期间使用的运动。 当 InteractionTracker 处于惯性状态并且必须解析为 Float 类型时,表达式将每帧计算一次,否则在计算公式时将引发错误。 有关生成表达式的更多详细信息,请参阅 ExpressionAnimation 类页。

Properties

CompositionObject 关联的属性的集合。

(继承自 CompositionObject)

方法

Close()

关闭 CompositionObject 并释放系统资源。

(继承自 CompositionObject)
Create(Compositor)

创建 InteractionTrackerInertiaMotion 的实例。

Dispose()

执行与释放或重置非托管资源关联的应用程序定义的任务。

(继承自 CompositionObject)
PopulatePropertyInfo(String, AnimationPropertyInfo)

定义可进行动画处理的属性。

(继承自 CompositionObject)
StartAnimation(String, CompositionAnimation)

使用 对象的指定属性连接动画并启动动画。

(继承自 CompositionObject)
StartAnimation(String, CompositionAnimation, AnimationController)

使用 对象的指定属性连接动画并启动动画。

(继承自 CompositionObject)
StartAnimationGroup(ICompositionAnimationBase)

启动动画组。

CompositionObject 上的 StartAnimationGroup 方法可用于启动 CompositionAnimationGroup。 组中的所有动画将同时在 对象上启动。

(继承自 CompositionObject)
StopAnimation(String)

断开动画与指定属性的连接并停止动画。

(继承自 CompositionObject)
StopAnimationGroup(ICompositionAnimationBase)

停止动画组。

(继承自 CompositionObject)
TryGetAnimationController(String)

返回指定属性上运行的动画的 AnimationController。

(继承自 CompositionObject)

适用于

另请参阅