-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15_animations.qml
159 lines (129 loc) · 2.89 KB
/
15_animations.qml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// 1
Rectangle {
width: 400; height: 400
color: "lightblue"
Rectangle {
y: 150; width: 100; height: 100
color: "green"
NumberAnimation on x {
from: 0; to: 150
duration: 1000
}
}
}
// 2
Rectangle {
width: 400; height: 400; color: "lightblue"
Rectangle {
id: rect
x: 300; y: 300
width: 100; height: 100
}
NumberAnimation {
target: rect
properties: "x,y"
to: 150; duration: 1000
running: true
}
}
// 3
Rectangle {
width: 400; height: 400; color: "lightblue"
Rectangle {
id: rect
x: 300; y: 300
width: 100; height: 100
}
MouseArea {
anchors.fill: parent
onClicked: () => {
animation.to = rect.x === 150 ? 0 : 150
animation.running = true
}
}
NumberAnimation {
id: animation
target: rect
properties: "x,y"
to: 150; duration: 1000
// easing.type: Easing.OutBounce // EASING
}
}
// 4
Item {
width: 400; height: 400
Image {
id: rocket
source: "rocket.png"
anchors.centerIn: parent
smooth: true
RotationAnimation on rotation {
from: 45; to: 315
direction: RotationAnimation.Shortest // try to remove
duration: 1000
}
}
}
// 5
Rectangle {
color: "lightblue"
width: 300; height: 300
Rectangle {
id: rect
x: 100; y: 100
width: 50; height: 50
color: "red"
Behavior on x { SpringAnimation { spring: 1; damping: 0.2 } }
Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } }
}
MouseArea {
anchors.fill: parent
onClicked: {
rect.x = mouse.x - rect.width/2
rect.y = mouse.y - rect.height/2
}
}
}
// 6
Rectangle {
width: 300; height: 300; color: "#000040"
Image {
id: rocket
anchors.centerIn: parent
source: "rocket.png"
}
SequentialAnimation {
NumberAnimation {
target: rocket; properties: "scale"
from: 1.0; to: 0.5; duration: 1000
}
// PauseAnimation {
// duration: 500
// }
NumberAnimation {
target: rocket; properties: "opacity"
from: 1.0; to: 0.0; duration: 1000
}
running: true
}
}
// 7
Rectangle {
width: 300; height: 300; color: "#000040"
Image {
id: rocket
anchors.centerIn: parent
source: "rocket.png"
}
ParallelAnimation {
NumberAnimation {
target: rocket; properties: "scale"
from: 1.0; to: 0.5; duration: 1000
}
NumberAnimation {
target: rocket; properties: "opacity"
from: 1.0; to: 0.0; duration: 1000
}
running: true
}
}