Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 986c87a

Browse files
committed
Updated the article for the 1.4.0 release.
1 parent 3b30b8f commit 986c87a

File tree

3 files changed

+51
-15
lines changed

3 files changed

+51
-15
lines changed

ApiReference/ui/animation/HOW-TO.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ label.animate({
3131
# Cancelling animation
3232
``` JavaScript
3333
var animation1 = label.createAnimation({ translate: { x: 100, y: 100 } });
34-
animation1.play().finished
34+
animation1.play()
3535
.then(function () {
3636
//console.log("Animation finished");
3737
})
@@ -61,12 +61,12 @@ label.animate({ opacity: 0 })
6161
``` JavaScript
6262
var animation1 = label.createAnimation({ translate: { x: 100, y: 100 } });
6363
var animation2 = label.createAnimation({ translate: { x: 0, y: 0 } });
64-
animation1.play().finished
65-
.then(function () { return animation1.play().finished; })
66-
.then(function () { return animation1.play().finished; })
67-
.then(function () { return animation2.play().finished; })
68-
.then(function () { return animation1.play().finished; })
69-
.then(function () { return animation2.play().finished; })
64+
animation1.play()
65+
.then(function () { return animation1.play(); })
66+
.then(function () { return animation1.play(); })
67+
.then(function () { return animation2.play(); })
68+
.then(function () { return animation1.play(); })
69+
.then(function () { return animation2.play(); })
7070
.then(function () {
7171
//console.log("Animation finished");
7272
})
@@ -82,7 +82,7 @@ var animations = [
8282
{ target: label3, translate: { x: 200, y: 200 }, duration: 1000, delay: 666 },
8383
];
8484
var a = new animation.Animation(animations);
85-
a.play().finished
85+
a.play()
8686
.then(function () {
8787
//console.log("Animations finished");
8888
})

animation.md

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
nav-title: Animation
3-
title: "Animation"
3+
title: "UI: Animation"
44
description: Learn how to animate view properties.
55
position: 18
66
---
@@ -186,7 +186,7 @@ definitions.push({ target: view3, translate: { x: -200, y: 0 }, duration: 3000 }
186186
definitions.push({ target: view4, translate: { x: 0, y: -200 }, duration: 3000 });
187187
var playSequentially = true;
188188
var animationSet = new animationModule.Animation(definitions, playSequentially);
189-
animationSet.play().finished.then(function () {
189+
animationSet.play().then(function () {
190190
console.log("Animation finished");
191191
})
192192
.catch(function (e) {
@@ -201,7 +201,7 @@ definitions.push({target: view3, translate: {x: -200, y: 0}, duration: 3000 });
201201
definitions.push({target: view4, translate: {x: 0, y: -200}, duration: 3000 });
202202
var playSequentially = true;
203203
var animationSet = new animationModule.Animation(definitions, playSequentially);
204-
animationSet.play().finished.then(() => {
204+
animationSet.play().then(() => {
205205
console.log("Animation finished");
206206
})
207207
.catch((e) => {
@@ -238,7 +238,7 @@ var a4 = {
238238
};
239239
definitions.push(a4);
240240
var animationSet = new animationModule.Animation(definitions);
241-
animationSet.play().finished.then(function () {
241+
animationSet.play().then(function () {
242242
console.log("Animation finished");
243243
})
244244
.catch(function (e) {
@@ -277,7 +277,43 @@ definitions.push(a4);
277277

278278
var animationSet = new animationModule.Animation(definitions);
279279

280-
animationSet.play().finished.then(() => {
280+
animationSet.play().then(() => {
281+
console.log("Animation finished");
282+
})
283+
.catch((e) => {
284+
console.log(e.message);
285+
});
286+
```
287+
288+
## Reusing Animations
289+
![reusing](img/modules/animation/reusing.gif "Reusing Animations")
290+
``` JavaScript
291+
var animation1 = view.createAnimation({ opacity: 0 });
292+
var animation2 = view.createAnimation({ opacity: 1 });
293+
animation1.play()
294+
.then(function () { return animation2.play(); })
295+
.then(function () { return animation1.play(); })
296+
.then(function () { return animation2.play(); })
297+
.then(function () { return animation1.play(); })
298+
.then(function () { return animation2.play(); })
299+
.then(function () {
300+
console.log("Animation finished");
301+
})
302+
.catch(function (e) {
303+
console.log(e.message);
304+
});
305+
```
306+
``` TypeScript
307+
var animation1 = view.createAnimation({opacity: 0});
308+
var animation2 = view.createAnimation({opacity: 1});
309+
310+
animation1.play()
311+
.then(()=>animation2.play())
312+
.then(()=>animation1.play())
313+
.then(()=>animation2.play())
314+
.then(()=>animation1.play())
315+
.then(()=>animation2.play())
316+
.then(() => {
281317
console.log("Animation finished");
282318
})
283319
.catch((e) => {
@@ -324,7 +360,7 @@ animationSet = new animationModule.Animation([{
324360
iterations: Number.POSITIVE_INFINITY,
325361
curve: view.ios ? UIViewAnimationCurve.UIViewAnimationCurveLinear : new android.view.animation.LinearInterpolator
326362
}]);
327-
animationSet.play().finished.catch(function (e) {
363+
animationSet.play().catch(function (e) {
328364
console.log("Animation stoppped!");
329365
});
330366
// Call animationSet.cancel() to stop it;
@@ -337,7 +373,7 @@ animationSet = new animationModule.Animation([{
337373
iterations: Number.POSITIVE_INFINITY,
338374
curve: view.ios ? UIViewAnimationCurve.UIViewAnimationCurveLinear : new android.view.animation.LinearInterpolator
339375
}]);
340-
animationSet.play().finished.catch((e) => {
376+
animationSet.play().catch((e) => {
341377
console.log("Animation stoppped!");
342378
});
343379
// Call animationSet.cancel() to stop it;

img/modules/animation/reusing.gif

127 KB
Loading

0 commit comments

Comments
 (0)