-
Notifications
You must be signed in to change notification settings - Fork 11
/
FollowMouseCircle.qml
85 lines (73 loc) · 1.62 KB
/
FollowMouseCircle.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
import QtQuick 2.0
import Material 0.1
// Should be placed directly under a MouseArea
Item {
id: root
property alias radius: followRect.radius
property string color: "blue"
states: [
State {
name: "hidden"
PropertyChanges { target: followRect; scale: 0.0 }
StateChangeScript {
script: breatheAnimation.stop();
}
},
State {
name: "shown"
PropertyChanges { target: followRect; scale: 1.0 }
StateChangeScript {
script: breatheAnimation.start();
}
}
]
state: "hidden"
transitions: [
Transition {
from: "hidden"; to: "shown"
NumberAnimation { properties: "scale"; easing.type: Easing.OutExpo; duration: 200 }
},
Transition {
from: "shown"; to: "hidden"
NumberAnimation { properties: "scale"; easing.type: Easing.InExpo; duration: 200 }
}
]
Rectangle {
id: followRect
radius: Units.dp(50)
width: radius * 2
height: radius * 2
color: Palette.colors[root.color]["300"]
opacity: 0.4
property real targetX: root.parent.mouseX
property real targetY: root.parent.mouseY
x: targetX - radius * scale
y: targetY - radius * scale
property real scale: 0.0
transformOrigin: Item.Center
transform: Scale {
xScale: followRect.scale
yScale: followRect.scale
}
SequentialAnimation on scale {
id: breatheAnimation
running: false
PauseAnimation {
duration: 200
}
SequentialAnimation {
loops: Animation.Infinite
PropertyAnimation {
duration: 2000
to: 1.5
easing.type: Easing.InOutQuad
}
PropertyAnimation {
duration: 2000
to: 1.00
easing.type: Easing.InOutQuad
}
}
}
}
}