on xenial help sign in
Simplify launcher tease logic while also implementing better easing like design wants
commitfcbe19734efb322da5219f68483ba323b29ee46d authorMichael Terry <michael.terry@canonical.com> dateWed 7 Jan 2015, 17:16 (12 years ago) parent9e9d0c8
2 files changed+29−20
qml/Launcher/Launcher.qml+8−13 qml/Tutorial/TutorialLeft.qml+21−7
qml/Launcher/Launcher.qml+8−13
@@ -70,12 +70,8 @@ Item {
7070 animateTimer.start();
7171 }
7272
73− function tease(interval) {
74− if (available && root.state == "" && !dragArea.dragging) {
75− if (interval === undefined) {
76− interval = 200;
77− }
78− teaseTimer.interval = interval;
73+ function tease() {
74+ if (available && !dragArea.dragging) {
7975 teaseTimer.mode = "teasing"
8076 teaseTimer.start();
8177 }
@@ -83,7 +79,6 @@ Item {
8379
8480 function hint() {
8581 if (available && root.state == "") {
86− teaseTimer.interval = 300;
8782 teaseTimer.mode = "hinting"
8883 teaseTimer.start();
8984 }
@@ -91,7 +86,8 @@ Item {
9186
9287 Timer {
9388 id: teaseTimer
94− property string mode
89+ interval: mode == "teasing" ? 200 : 300
90+ property string mode: "teasing"
9591 }
9692
9793 Timer {
@@ -214,7 +210,7 @@ Item {
214210 bottom: parent.bottom
215211 }
216212 x: -width
217− visible: x > -width || dragArea.status === DirectionalDragArea.Undecided
213+ visible: root.x > 0 || x > -width || dragArea.status === DirectionalDragArea.Undecided
218214 model: LauncherModel
219215
220216 property bool animate: true
@@ -256,6 +252,7 @@ Item {
256252 direction: Direction.Rightwards
257253
258254 enabled: root.available
255+ x: -root.x // so if launcher is adjusted relative to screen, we stay put (like tutorial does when teasing)
259256 width: root.dragAreaWidth
260257 height: root.height
261258
@@ -269,7 +266,7 @@ Item {
269266 // would appear right next to the user's finger out of nowhere.
270267 // Instead, we make the panel go towards the user's finger in several
271268 // steps. ie., in an animated way.
272− var targetPanelX = Math.min(0, touchX - panel.width)
269+ var targetPanelX = Math.min(0, touchX - panel.width) - root.x
273270 var delta = targetPanelX - panel.x
274271 // the trick is not to go all the way (1.0) as it would cause a sudden jump
275272 panel.x += 0.4 * delta
@@ -285,8 +282,6 @@ Item {
285282 } else {
286283 root.switchToNextState("")
287284 }
288− } else {
289− teaseTimer.stop();
290285 }
291286 }
292287 }
@@ -303,7 +298,7 @@ Item {
303298 name: "visible"
304299 PropertyChanges {
305300 target: panel
306− x: 0
301+ x: -root.x // so we never go past panelWidth, even when teased by tutorial
307302 }
308303 },
309304 State {
qml/Tutorial/TutorialLeft.qml+21−7
@@ -45,12 +45,25 @@ TutorialPage {
4545 }
4646 }
4747
48− Timer {
49− id: teaseTimer
50− interval: UbuntuAnimation.SleepyDuration
51− repeat: true
52− running: !root.paused && !root.launcher.dragging
53− onTriggered: root.launcher.tease(UbuntuAnimation.SleepyDuration)
48+ SequentialAnimation {
49+ id: teaseAnimation
50+ paused: running && root.paused
51+ running: !slider.active && root.launcher.visibleWidth === 0
52+ loops: Animation.Infinite
53+ alwaysRunToEnd: true
54+
55+ UbuntuNumberAnimation {
56+ target: root.launcher
57+ property: "x"
58+ to: units.gu(2)
59+ duration: UbuntuAnimation.SleepyDuration
60+ }
61+ UbuntuNumberAnimation {
62+ target: root.launcher
63+ property: "x"
64+ to: 0
65+ duration: UbuntuAnimation.SleepyDuration
66+ }
5467 }
5568
5669 Timer {
@@ -62,12 +75,13 @@ TutorialPage {
6275 foreground {
6376 children: [
6477 LocalComponents.Slider {
78+ id: slider
6579 anchors {
6680 left: parent.left
6781 top: parent.top
6882 topMargin: root.textBottom + units.gu(3)
6983 }
70− offset: root.launcher.visibleWidth + root.launcher.progress
84+ offset: root.launcher.x + root.launcher.visibleWidth + root.launcher.progress
7185 active: root.launcher.dragging
7286 shortSwipe: true
7387 }