InteractionTracker.TryUpdatePositionWithAnimation Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Tries to update the InteractionTracker's position by applying an animation.
The TryUpdatePositionWithAnimation method updates the position of InteractionTracker based on the CompositionAnimation input 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. TryUpdatePositionWithAnimation 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 TryUpdatePositionWithAnimation(CompositionAnimation ^ animation) = TryUpdatePositionWithAnimation;
int TryUpdatePositionWithAnimation(CompositionAnimation const& animation);
public int TryUpdatePositionWithAnimation(CompositionAnimation animation);
function tryUpdatePositionWithAnimation(animation)
Public Function TryUpdatePositionWithAnimation (animation As CompositionAnimation) As Integer
Parameters
- animation
- CompositionAnimation
The animation to apply to the InteractionTracker.
Returns
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(Vector3 newPosition)
{
// 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
Vector3KeyFrameAnimation kfa = _compositor.CreateVector3KeyFrameAnimation();
kfa.Duration = TimeSpan.FromSeconds(3);
// Create the KeyFrames
kfa.InsertKeyFrame(1.0f, newPosition, cubicBezier);
// Update InteractionTracker position using this animation
_tracker.TryUpdatePositionWithAnimation(kfa);
}
Remarks
When creating the animation you want to update InteractionTracker ’s position with, you do not need to call Microsoft.UI.Composition.CompositionObject.StartAnimation. The system will take care of this behind the scenes once the animation is passed in via TryUpdatePositionWithAnimation.
When defining the animation that will animate InteractionTracker ’s position, be sure to either use a Vector3KeyFrameAnimation or an ExpressionAnimation that resolves to a Vector3.
The table below summarizes the expected behavior when this method is called in a particular state:
Current State | Outcome |
---|---|
Idle | Requested animation starts on requested property, state changes to CustomAnimation |
Interacting | Request ignored |
Inertia | Requested animation starts on requested property, state changes to CustomAnimation |
CustomAnimation | Current animation stops and new requested animation starts on requested property, state re-enters CustomAnimation |