Loading...
Loading...
Compare original and translation side by side
VisualElementTask<bool>awaitVisualElementTask<bool>await| Method | Description |
|---|---|
| Animate |
| Animate |
| Animate |
| Animate |
| Animate |
| Animate |
| Animate |
| Animate |
| Relative scale increment |
| Relative rotation increment |
lengtheasingEasing.Linearview.CancelAnimations()| 方法 | 描述 |
|---|---|
| 对 |
| 对 |
| 对 |
| 对 |
| 对视图执行均匀缩放动画 |
| 对 |
| 对 |
| 对 |
| 相对增量缩放动画 |
| 相对增量旋转动画 |
lengtheasingEasing.Linearview.CancelAnimations()// Parallel – all run at the same time
await Task.WhenAll(
view.FadeTo(1, 500),
view.ScaleTo(1.5, 500),
view.RotateTo(360, 500));
// Sequential – one after the other
await view.FadeTo(0, 250);
await view.TranslateTo(100, 0, 500);
await view.FadeTo(1, 250);// Parallel – all run at the same time
await Task.WhenAll(
view.FadeTo(1, 500),
view.ScaleTo(1.5, 500),
view.RotateTo(360, 500));
// Sequential – one after the other
await view.FadeTo(0, 250);
await view.TranslateTo(100, 0, 500);
await view.FadeTo(1, 250);Animationvar parent = new Animation();
// Child animations with begin/end ratios (0.0–1.0)
parent.Add(0.0, 0.5, new Animation(v => view.Opacity = v, 0, 1));
parent.Add(0.5, 1.0, new Animation(v => view.Scale = v, 1, 2, Easing.SpringOut));
// Commit to run
parent.Commit(
owner: view,
name: "MyAnimation",
rate: 16, // ms per frame
length: 1000, // total duration ms
easing: Easing.Linear,
finished: (v, cancelled) => { /* cleanup */ },
repeat: () => false); // return true to loopAnimationvar parent = new Animation();
// Child animations with begin/end ratios (0.0–1.0)
parent.Add(0.0, 0.5, new Animation(v => view.Opacity = v, 0, 1));
parent.Add(0.5, 1.0, new Animation(v => view.Scale = v, 1, 2, Easing.SpringOut));
// Commit to run
parent.Commit(
owner: view,
name: "MyAnimation",
rate: 16, // ms per frame
length: 1000, // total duration ms
easing: Easing.Linear,
finished: (v, cancelled) => { /* cleanup */ },
repeat: () => false); // return true to loopnew Animation(
callback: v => view.Scale = v, // Action<double>
start: 0.0,
end: 1.0,
easing: Easing.CubicInOut);new Animation(
callback: v => view.Scale = v, // Action<double>
start: 0.0,
end: 1.0,
easing: Easing.CubicInOut);view.AbortAnimation("MyAnimation");Gotcha: Returningfrom a child animation'struecallback does not repeat the parent animation. Only therepeatcallback passed torepeaton the parent controls parent repetition.Commit
view.AbortAnimation("MyAnimation");注意事项: 从子动画的回调中返回repeat不会重复父动画。只有传递给父动画true方法的Commit回调才能控制父动画的重复。repeat
view.Animate<double>(
name: "opacity",
transform: v => v, // Func<double, T>
callback: v => view.Opacity = v,
rate: 16,
length: 500,
easing: Easing.SinInOut,
finished: (v, cancelled) => { });view.Animate<double>(
name: "opacity",
transform: v => v, // Func<double, T>
callback: v => view.Opacity = v,
rate: 16,
length: 500,
easing: Easing.SinInOut,
finished: (v, cancelled) => { });| Easing | Curve |
|---|---|
| Constant speed |
| Smooth accelerate |
| Smooth decelerate |
| Smooth both |
| Sharp accelerate |
| Sharp decelerate |
| Sharp both |
| Bounce at start |
| Bounce at end |
| Spring at start |
| Spring at end |
| 缓动函数 | 曲线描述 |
|---|---|
| 匀速 |
| 平滑加速 |
| 平滑减速 |
| 先加速后减速,平滑过渡 |
| 急剧加速 |
| 急剧减速 |
| 先急剧加速后急剧减速 |
| 起始处弹跳 |
| 结束处弹跳 |
| 起始处弹性效果 |
| 结束处弹性效果 |
var customEase = new Easing(t => t * t * t);
await view.ScaleTo(2, 500, customEase);var customEase = new Easing(t => t * t * t);
await view.ScaleTo(2, 500, customEase);VisualElement.IsAnimationEnabledfalseif (view.IsAnimationEnabled)
await view.FadeTo(1, 500);
else
view.Opacity = 1;VisualElement.IsAnimationEnabledfalseif (view.IsAnimationEnabled)
await view.FadeTo(1, 500);
else
view.Opacity = 1;