Share via


InteractionTrackerInertiaRestingValue 类

定义

一个 ExpressionAnimation,用于定义交互后的休息位置。

InteractionTrackerInertiaRestingValue 类定义两个 ExpressionAnimation,用于在满足特定条件时计算 InteractionTracker 的显式静态位置。 InteractionTrackerInertiaRestingValue 定义为两个部分:需要显式定义 InteractionTracker 的特定静态位置的条件语句(如果为 true),以及描述输出位置的数学关系的公式。 当需要确保 InteractionTracker 在交互发生后登陆到特定位置时,请使用 InteractionTrackerInertiaRestingValue 类。

public ref class InteractionTrackerInertiaRestingValue 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 InteractionTrackerInertiaRestingValue 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 InteractionTrackerInertiaRestingValue 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 InteractionTrackerInertiaRestingValue : 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 InteractionTrackerInertiaRestingValue : InteractionTrackerInertiaModifier
Public NotInheritable Class InteractionTrackerInertiaRestingValue
Inherits InteractionTrackerInertiaModifier
继承
Object Platform::Object IInspectable CompositionObject InteractionTrackerInertiaModifier InteractionTrackerInertiaRestingValue
属性

示例

void MandatorySingleSnapPoints(ContainerVisual containerVisual, Visual contentVisual)
{
  //
  // Set up our inertia modifiers to behave as dmanip's "single mandatory" snap-points, at a
  // regular interval of 50px.
  //

  const float snapPointRange = 50.0f;

  //
  // Configure a "snap-point" to handle upward direction (to previous item).
  //

  var modifier1 = InteractionTrackerInertiaRestingValue.Create(_compositor);

  // Add a condition for when this upward “snap-point” applies.
  modifier1.Condition = _compositor.CreateExpressionAnimation(
    "this.Target.NaturalRestingPosition.y < " + 
    "(this.StartingValue - mod(this.StartingValue, snapPointRange) + snapPointRange / 2)");

  modifier1.Condition.SetScalarParameter("snapPointRange", snapPointRange);

  // Configure the resting spot when the condition is met 
  modifier1.EndPoint = _compositor.CreateExpressionAnimation(
    "this.StartingValue - mod(this.StartingValue, snapPointRange)");

  modifier1.EndPoint.SetScalarParameter("snapPointRange", snapPointRange);

  //
  // Configure a "snap-point" to handle downward direction (to next item).
  //

  var modifier2 = InteractionTrackerInertiaRestingValue.Create(_compositor);

  // Add a condition for when this downward “snap-point” applies.
  modifier2.Condition = _compositor.CreateExpressionAnimation(
    "this.Target.NaturalRestingPosition.y >= " + 
    "(this.StartingValue - mod(this.StartingValue, snapPointRange) + snapPointRange / 2)");

  modifier2.Condition.SetScalarParameter("snapPointRange", snapPointRange);

  // Configure the resting spot when the condition is met.
  modifier2.EndPoint = _compositor.CreateExpressionAnimation(
    "this.StartingValue + snapPointRange - mod(this.StartingValue, snapPointRange)");

  modifier2.EndPoint.SetScalarParameter("snapPointRange", snapPointRange);

  var modifiers = new InteractionTrackerInertiaRestingValue[] { modifier1, modifier2 };

  //
  // Add our "snap-point" inertia modifiers to the Y position of the InteractionTracker.
  //

  _tracker.ConfigurePositionYInertiaModifiers(modifiers);
}

注解

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

当交互完成时,定义条件属性的 ExpressionAnimation 仅运行一次, (手指松开) ,而 RestingValue Expression 将运行每个帧。

InteractionTrackerInertiaRestingValue 修饰符在满足条件时显式定义 InteractionTracker 的静态位置。 但是,它并不定义到此显式位置的运动 - 系统将处理该动作。 因此,如果需要 InteractionTracker 采取特定动作,但不需要它降落在精确位置,请使用 InteractionTrackerInertiaMotion 修饰符。

属性

Comment

要与 CompositionObject 关联的字符串。

(继承自 CompositionObject)
Compositor

用于创建此 CompositionObject 的 Compositor

(继承自 CompositionObject)
Condition

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

Condition 属性是 ExpressionAnimation ,用于定义 InteractionTracker 何时应具有特定的静态位置。 此表达式在交互发生后运行一次,并且必须解析为 Bool 类型,否则在计算条件时将引发错误。 有关生成表达式的更多详细信息,请参阅 ExpressionAnimation 类页。

DispatcherQueue

获取 CompositionObject 的 DispatcherQueue。

(继承自 CompositionObject)
ImplicitAnimations

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

(继承自 CompositionObject)
Properties

CompositionObject 关联的属性的集合。

(继承自 CompositionObject)
RestingValue

一个 ExpressionAnimation ,用于定义 InteractionTracker 的静态值(如果 Condition 属性中的表达式为 true)。

Resting 属性是 ExpressionAnimation ,用于描述交互后,如果满足相应的条件, 则 InteractionTracker 将移动到的位置。 当 InteractionTracker 处于惯性状态并且必须解析为 Float 类型时,将每帧运行此表达式,否则在计算公式时将引发错误。 有关生成表达式的更多详细信息,请参阅 ExpressionAnimation 类页。

方法

Close()

关闭 CompositionObject 并释放系统资源。

(继承自 CompositionObject)
Create(Compositor)

创建 InteractionTrackerInertiaRestingValue 的实例。

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)

适用于

另请参阅