Partage via


InteractionTracker.NaturalRestingScale Propriété

Définition

Échelle de repos naturelle pour InteractionTracker.

La propriété NaturalRestingScale est la position d’échelle calculée à laquelle InteractionTracker s’arrête sans prendre en compte les limites ou les modificateurs d’inertie. Cette propriété est souvent utile pour des actions telles que la virtualisation dans une expérience de défilement, où il est important de connaître l’emplacement où InteractionTracker s’arrêtera . Il existe deux cas d’usage main pour utiliser la propriété NaturalRestingScale : récupérer sa valeur actuelle dans les arguments d’événement InertieStateEntered ou référencer cette propriété dans une ExpressionAnimation lors de la création d’éléments tels que des modificateurs d’inertie.

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

Valeur de propriété

Single

float

Échelle de repos naturelle pour InteractionTracker.

Exemples

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

Remarques

Les deux cas d’usage décrits dans l’extrait de code sont les principales utilisations de la propriété NaturalRestingScale. Bien que vous soyez tenté de référencer cette propriété sur InteractionTracker comme toute autre relation object.property, vous n’obtiendrez pas toujours la valeur la plus récente. Dans ce cas, il est recommandé d’écouter l’événement InertieStateEntered et de récupérer la valeur la plus récente à partir des arguments.

S’applique à