Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit e5020f1

Browse files
Todd Anglintjvantoll
Todd Anglin
authored andcommitted
Added Playground examples for animations
Also added resource for finding custom cubic bezier curve values.
1 parent b3baff4 commit e5020f1

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

‎docs/ui/animation.md‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,22 @@ __Example 1: Changing background color animation with code.__
2626
![hello-world](../img/modules/animation/hello-world.gif "Hello world")
2727

2828
``` JavaScript
29+
// Import color module
30+
var colorModule = require("color");
31+
2932
view.backgroundColor = new colorModule.Color("red");
3033
view.animate({ backgroundColor: new colorModule.Color("green"), duration: 2000 });
3134
```
3235
``` TypeScript
33-
view.backgroundColor = new colorModule.Color("red");
34-
view.animate({ backgroundColor: new colorModule.Color("green"), duration: 2000 });
36+
// Import color module
37+
import { Color } from 'color';
38+
39+
view.backgroundColor = new Color("red");
40+
view.animate({ backgroundColor: new Color("green"), duration: 2000 });
3541
```
3642

43+
[Try this animation in the NativeScript Playground](https://play.nativescript.org/?template=play-tsc&id=RE7NqF&v=5)
44+
3745
As _Example 2_ shows, you can express the same animation in CSS with the following definition:
3846

3947
__Example 2: Changing background color animation with CSS.__
@@ -49,9 +57,15 @@ __Example 2: Changing background color animation with CSS.__
4957
animation-fill-mode: forwards;
5058
}
5159
```
60+
``` XML
61+
<!-- Apply CSS class to element to trigger CSS animation -->
62+
<Label class="view" text="{N}"></Label>
63+
```
5264

5365
> CSS animations apply with lower precedence, like any other CSS settings, so any local values set in your element will cancel the animation.
5466
67+
[Try this animation in the NativeScript Playground](https://play.nativescript.org/?template=play-tsc&id=RE7NqF&v=2)
68+
5569
NativeScript lets you animate the following properties:
5670

5771
- **opacity**
@@ -119,7 +133,11 @@ view.animate({
119133
}
120134
```
121135

122-
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 (as shown in __Example 4__). 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.
136+
[Experiment with the different animation timing functions in the NativeScript Playground](https://play.nativescript.org/?template=play-tsc&id=RE7NqF&v=6)
137+
138+
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 (as shown in __Example 4__). 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.
139+
140+
For help finding the `cubicBezier` values you need for your custom animation timing function, use the visual tools on [cubic-bezier.com](http://cubic-bezier.com). Once you find an animation path you like, simply copy and paste the cubic bezier values and paste them in the `AnimationCurve.cubicBezier` function. Their should be four numbers (X,Y coordinates for each of the two points in the animation).
123141

124142
__Example 4: How to create own animation curve via cubic Bezier__
125143

@@ -152,6 +170,8 @@ view.animate({
152170

153171
![bezier](../img/modules/animation/bezier.gif "Bezier")
154172

173+
174+
155175

156176
More detailed examples are available on the [Animation Examples](./animation-examples.md) page.
157177

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /