on xenial help sign in
Different drag behaviour for not closable apps in spread Fixes: #1368287

Approved by: Albert Astals Cid

commita3c51466e9169bf443ed1fd0ec71211e1f991934 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 2 Dec 2014, 09:26 (12 years ago) parent32035a441d5b09
2 files changed+16−6
qml/Stages/SpreadDelegate.qml+8−1 tests/qmltests/Stages/tst_SpreadDelegate.qml+8−5
qml/Stages/SpreadDelegate.qml+8−1
@@ -41,10 +41,17 @@ Item {
4141 Item {
4242 objectName: "appWindowWithShadow"
4343
44− y: dragArea.distance
44+ readonly property real limit: root.height / 4
45+
46+ y: root.closeable ? dragArea.distance : elastic(dragArea.distance)
4547 width: parent.width
4648 height: parent.height
4749
50+ function elastic(distance) {
51+ var k = distance < 0 ? -limit : limit
52+ return k * (1 - Math.pow((k - 1) / k, distance))
53+ }
54+
4855 BorderImage {
4956 anchors {
5057 fill: appWindow
tests/qmltests/Stages/tst_SpreadDelegate.qml+8−5
@@ -110,7 +110,7 @@ Rectangle {
110110 {tag: "swipeToClose=true closeable=true -> appWindow moves away",
111111 swipeToClose: true, closeable: true },
112112
113− {tag: "swipeToClose=true closeable=alse -> appWindow bounces back",
113+ {tag: "swipeToClose=true closeable=false -> appWindow bounces back",
114114 swipeToClose: true, closeable: false },
115115
116116 {tag: "swipeToClose=false -> appWindow stays put",
@@ -134,13 +134,16 @@ Rectangle {
134134 touchX /* fromX */, fromY, touchX /* toX */, toY,
135135 true /* beginTouch */, false /* endTouch */, dragArea.minSpeedToClose * 1.1 /* speed */);
136136
137−
138137 if (data.swipeToClose) {
139138 verify(appWindowWithShadow.y < 0);
140139 var threshold = findChild(spreadDelegateLoader.item, "dragArea").threshold
141− // Verify that the delegate started moving exactly "threshold" after the finger movement
142− // and did not jump up to the finger, but lags the threshold behind
143− compare(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance), threshold);
140+ if (data.closeable) {
141+ // Verify that the delegate started moving exactly "threshold" after the finger movement
142+ // and did not jump up to the finger, but lags the threshold behind
143+ compare(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance), threshold);
144+ } else {
145+ verify(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance) > threshold);
146+ }
144147
145148 touchRelease(spreadDelegateLoader.item, touchX, toY - units.gu(1));
146149