共用方式為


InteractionTracker.NaturalRestingScale 屬性

定義

InteractionTracker的自然靜止縮放比例。

NaturalRestingScale 屬性是 InteractionTracker 不會考慮界限或慣性修飾詞而停止的計算縮放位置。 此屬性通常用於捲動體驗中虛擬化之類的動作,其中請務必知道 InteractionTracker 將停止的位置。 使用 NaturalRestingScale 屬性有兩個主要使用案例:在 InertiaStateEntered 事件引數中擷取其目前值,或在 建立 慣性修飾詞之類的專案時參考此屬性。

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

屬性值

Single

float

InteractionTracker的自然靜止縮放比例。

範例

// Listen for the InertiaStateEntered event
public void InertiaStateEntered(InteractionTracker sender, 	InteractionTrackerInertiaStateEnteredArgs args)
{
  // Grab the NaturalRestingScale out of the args when the event is fired.
  float scaleRest = args.NaturalRestingScale;
}
void CreateBasicScaleSnapPoint(float maxScale, float minScale)
{
  var snappoint = InteractionTrackerInertiaRestingValue.Create(_compositor);

  // Reference the NaturalRestingScale of InteractionTracker in an ExpressionAnimation for conditional portion of an InertiaModifier.
  snappoint.Condition = _compositor.CreateExpressionAnimation("this.target.NaturalRestingScale >= min && this.target.NaturalRestingScale < max ");

  snappoint.Condition.SetScalarParameter("min", minScale);
  snappoint.Condition.SetScalarParameter("max", maxScale);

  // Snap to the highbound if condition met
  snappoint.RestingValue = _compositor.CreateExpressionAnimation("max");
  snappoint.RestingValue.SetScalarParameter("max", maxScale);

  scaleInertiaModifier.Add(snappoint);

  _tracker.ConfigureScaleInertiaModifiers(scaleInertiaModifier);
}

備註

程式碼片段中所述的兩個使用案例是 NaturalRestingScale 屬性的主要用途。 雖然您可能想要像任何其他 object.property 關聯性一樣參考這個屬性,但 不一定會取得最新的值。 在此情況下,建議您接聽 InertiaStateEntered 事件,並從引數擷取最新的值。

適用於