You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ui/animation.md
+66Lines changed: 66 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,71 @@ The [`Animation`]({{site.baseurl}}/ApiReference/ui/animation/Animation.md) class
42
42
## View.animate Method
43
43
In case you need to animate a **single**[`View`]({{site.baseurl}}/ApiReference/ui/core/view/View.md) and you don't need to be able to **cancel** the animation, you can simply use the shortcut **View.animate** method which accepts an [`AnimationDefinition`]({{site.baseurl}}/ApiReference/ui/animation/AnimationDefinition.md), immediately starts the animation and returns its finished promise.
44
44
45
+
## Animation curves
46
+
47
+
By default the animation moves with a linear speed without acceleration or deceleration. This might look unnatural and different from the real world where objects need time to reach their top speed and can't stop immediately. The animation curve (called sometimes easing function) is used to give animations an illusion of inertia. It controls the animation speed by modifying the fraction of the duration. NativeScript comes with a number of predefined animation curves:
48
+
49
+
- The simplest animation curve is linear. It maintains a constant speed while the animation is running:
- An ease-in ease-out curve causes the animation to begin slowly, accelerate through the middle of its duration, and then slow again before completing.
In NativeScript the animation curve is represented by the AnimationCurve enumeration and can be specified with the curve property of the animation:
73
+
74
+
```JavaScript
75
+
view.animate({
76
+
translate: { x:0, y:100},
77
+
duration:1000,
78
+
curve:enums.AnimationCurve.easeIn
79
+
});
80
+
```
81
+
```TypeScript
82
+
view.animate({
83
+
translate: { x: 0, y: 100},
84
+
duration: 1000,
85
+
curve: enums.AnimationCurve.easeIn
86
+
});
87
+
```
88
+
89
+
It is easy to create your own animation curve by passing in the x and y components of two control points of a cubic Bezier curve. Using Bezier curves is a common technique to create smooth curves in computer graphics and they are widely used in vector-based drawing tools. The values passed to the cubicBezier method control the curve shape. The animation speed will be adjusted based on the resulting path.
0 commit comments