Dela via


InteractionTracker.TryUpdateScaleWithAnimation Method

Definition

Tries to update the scale with the specified animation.

The TryUpdateScaleWithAnimation method updates the scale position of InteractionTracker based on the CompositionAnimation inputted as a parameter. This method is used in situations in which the motion of InteractionTracker needs to be defined by a specific animation, instead of the traditional Inertia experience. TryUpdateScaleWithAnimation can be called from the Idle or Inertia state – doing so, InteractionTracker ’s position will be driven by the defined animation and enter the CustomAnimation state.

public:
 virtual int TryUpdateScaleWithAnimation(CompositionAnimation ^ animation, float3 centerPoint) = TryUpdateScaleWithAnimation;
int TryUpdateScaleWithAnimation(CompositionAnimation const& animation, float3 const& centerPoint);
public int TryUpdateScaleWithAnimation(CompositionAnimation animation, Vector3 centerPoint);
function tryUpdateScaleWithAnimation(animation, centerPoint)
Public Function TryUpdateScaleWithAnimation (animation As CompositionAnimation, centerPoint As Vector3) As Integer

Parameters

animation
CompositionAnimation

The animation to apply to the scale.

centerPoint
Vector3 Vector3

float3

The new center point.

Returns

Int32

int

Returns the request ID. On state transitions, the request which caused the change in state will be included in the args. These IDs will start at 1 and increase with each try call during the lifetime of the application.

Examples

void CustomAnimationForIT(float newScale, Vector3 newCenterPoint)
{
  // Create a cubic bezier easing function that will be used in the KeyFrames
  CompositionEasingFunction cubicBezier = _compositor.CreateCubicBezierEasingFunction(new Vector2(.17f, .67f), new Vector2(1f, 1f);

  // Create the Vector3 KFA
  ScalarKeyFrameAnimation kfa = _compositor.CreateScalarKeyFrameAnimation();
  kfa.Duration = TimeSpan.FromSeconds(3);

  // Create the KeyFrames
  kfa.InsertKeyFrame(1.0f, newScale, cubicBezier);

  // Update InteractionTracker position using this animation
  _tracker.TryUpdatePositionWithAnimation(kfa, newCenterPoint);
}

Remarks

When creating the animation you want to update InteractionTracker ’s position with, you do not need to call StartAnimation. The system will take care of this behind the scenes once the animation is passed in via TryUpdateScaleWithAnimation.

When defining the animation that will animate InteractionTracker ’s scale position, be sure to either use a ScalarKeyFrameAnimation or an ExpressionAnimation that resolves to a Scalar.

The table below summarizes the expected behavior when this method is called in a particular state:

Current StateOutcome
IdleRequested animation starts on requested property, state changes to CustomAnimation
InteractingRequest ignored
InertiaRequested animation starts on requested property, state changes to CustomAnimation
CustomAnimationCurrent animation stops and new requested animation starts on requested property, state re-enters CustomAnimation

Applies to