-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexamples.js
executable file
·105 lines (93 loc) · 1.89 KB
/
examples.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var window = Titanium.UI.createWindow();
var pink = Titanium.UI.createView({
backgroundColor: "#ff88ff",
width: 50,
height: 50,
top: 20
});
var blue = Titanium.UI.createView({
backgroundColor: "#0000ff",
width: 50,
height: 50,
bottom: 20
});
window.add(pink);
window.add(blue);
// Load the animator helper
var Animator = require("/Animator");
// Do animations in parallel manually
new Animator().scale({ view: pink, value: 2, duration: 500 });
new Animator().scale({ view: blue, value: 0.5, duration: 1500 });
// Do animations in sequence manually
new Animator().scale({
view: pink, value: 2, duration: 500, onComplete: function(){
new Animator().scale({ view: blue, value: 0.5, duration: 500 });
}
});
// shake it, baby
new Animator().shake({
view: blue
});
// do a couple of animations at the same time
new Animator().parallel([
{
type: "scale",
view: pink,
value: 1.5,
duration: 500 },
{
type: "scale",
view: blue,
value: 0.5,
duration: 500 }
]);
// do a bunch of animations one after the other
new Animator().sequence([
{
type: "scale",
view: pink,
value: 1.5,
duration: 500 },
{
type: "rotate",
view: pink,
value: 57,
duration: 500 } ,
{
type: "fade",
view: blue,
value: 0.8,
duration: 500 } ,
{
type: "moveTo",
view: pink,
value: {x: 0, y: 200 },
duration: 500 },
]);
// how about some loops?
function loopedAnimation() {
new Animator().sequence([
{
type: "scale",
view: pink,
value: 1.5,
duration: 500 },
{
type: "rotate",
view: pink,
value: 57,
duration: 500 } ,
{
type: "fade",
view: blue,
value: 0.8,
duration: 500 } ,
{
type: "moveTo",
view: pink,
value: {x: 0, y: 200 },
duration: 500, onComplete: loopedAnimation },
]);
}
// Run the looped animation
loopedAnimation();