InteractionTracker.ScaleVelocityInPercentPerSecond 属性

定义

缩放的更改率。

ScaleVelocityInPercentPerSecond 属性表示在惯性中 时 InteractionTracker 的当前刻度速度。 在交互发生后立即获取 InteractionTracker 的位置速度,或者在 ExpressionAnimation 中引用 InteractionTracker 的当前速度。

public:
 property float ScaleVelocityInPercentPerSecond { float get(); };
float ScaleVelocityInPercentPerSecond();
public float ScaleVelocityInPercentPerSecond { get; }
var single = interactionTracker.scaleVelocityInPercentPerSecond;
Public ReadOnly Property ScaleVelocityInPercentPerSecond As Single

属性值

Single

float

缩放的更改率。

示例

// Listen for the InertiaStateEntered event
public void InertiaStateEntered(InteractionTracker sender, 	InteractionTrackerInertiaStateEnteredArgs args)
{
  // Grab the Scale velocity out of the args when the event is fired. 
  float scaleVelocity = args.ScaleVelocityInPercentPerSecond;
}

void CustomSpringMotion(float springCoefficient, float dampingCoefficient, float 	maxScale)
{
  // Create the InertiaModifier that will be a custom motion emulating a spring
  InteractionTrackerInertiaMotion modifier = InteractionTrackerInertiaMotion.Create(_compositor);
  modifier.Condition = _compositor.CreateExpressionAnimation("this.Target.NaturalRestingPosition.X > maxScale");
  modifier.Condition.SetScalarParameter("maxScale", maxScale);

  // Utilize the current Velocity of InteractionTracker in the Expression defining 	the custom spring motion
  modifier.Motion = _compositor.CreateExpressionAnimation("(-springStiffnessCoefficient * (this.Target.Position.X – maxScale)) + " +
    "(-dampingCoefficient * this.target.ScaleVelocityInPercentPerSecond");
  modifier.Motion.SetScalarParameter("springStiffnessCoefficient", springCoefficient);
  modifier.Motion.SetScalarParameter("dampingCoefficient", dampingCoefficient);
  modifier.Motion.SetScalarParameter("maxScale", maxScale);
}

注解

InertiaStateEntered 事件访问 ScaleVelocityInPercentPerSecond 属性时,将根据交互检索计算速度的快照。 此事件仅在交互发生后触发一次。

适用于