@@ -857,6 +857,7 @@ AbstractStage {
857857 targetAngle: spreadMaths.targetAngle
858858 targetScale: spreadMaths.targetScale
859859 shuffledZ: stageMaths.itemZ
860+ breakPoint: spreadItem.rightEdgeBreakPoint
860861 }
861862
862863 WindowedRightEdgeMaths {
@@ -870,6 +871,7 @@ AbstractStage {
870871 normalZ: appDelegate.normalZ
871872 targetAngle: spreadMaths.targetAngle
872873 targetScale: spreadMaths.targetScale
874+ breakPoint: spreadItem.rightEdgeBreakPoint
873875 }
874876
875877 states: [
@@ -1206,6 +1208,17 @@ AbstractStage {
12061208 }
12071209 }
12081210 }
1211+ },
1212+ Transition {
1213+ from: "stagedRightEdge"; to: "staged"
1214+ SequentialAnimation {
1215+ ParallelAnimation {
1216+ UbuntuNumberAnimation { target: appDelegate; properties: "x,y,height,width,scale"; duration: priv.animationDuration }
1217+ UbuntuNumberAnimation { target: decoratedWindow; properties: "width,height,itemScale,angle,scaleToPreviewProgress"; duration: priv.animationDuration }
1218+ }
1219+ // // We need to release scaleToPreviewSize at last
1220+ PropertyAction { target: decoratedWindow; property: "scaleToPreviewSize" }
1221+ }
12091222 }
12101223
12111224 ]
@@ -1412,6 +1425,9 @@ AbstractStage {
14121425
14131426 onTouchPositionChanged: {
14141427 gesturePoints.push(touchPosition.x);
1428+ if (gesturePoints.length > 10) {
1429+ gesturePoints.splice(0, gesturePoints.length - 10)
1430+ }
14151431 }
14161432
14171433 onDraggingChanged: {
@@ -1421,11 +1437,29 @@ AbstractStage {
14211437 gesturePoints = [];
14221438 } else {
14231439 // Ok. The user released. Did he drag far enough to go to full spread?
1424− if (gesturePoints[gesturePoints.length - 1] < -units.gu(15) ) {
1425− print("gone to spread true")
1426− priv.goneToSpread = true;
1440+ if (gesturePoints[gesturePoints.length - 1] < -spreadItem.rightEdgeBreakPoint * spreadItem.width ) {
1441+
1442+ // He dragged far enough, but if the last movement was a flick to the right again, he wants to cancel the spread again.
1443+ var oneWayFlickToRight = true;
1444+ var smallestX = gesturePoints[0]-1;
1445+ for (var i = 0; i < gesturePoints.length; i++) {
1446+ print("have point:", gesturePoints[i])
1447+ if (gesturePoints[i] <= smallestX) {
1448+ oneWayFlickToRight = false;
1449+ break;
1450+ }
1451+ smallestX = gesturePoints[i];
1452+ }
1453+
1454+ if (!oneWayFlickToRight) {
1455+ // Ok, the user made it, let's go to spread!
1456+ priv.goneToSpread = true;
1457+// } else {
1458+// appRepeater.itemAt(0).playFocusAnimation();
1459+ }
14271460 } else {
1428− // Find out if it was a one-way movement.
1461+ // Ok, the user didn't drag far enough to cross the breakPoint
1462+ // Find out if it was a one-way movement to the left, in which case we just switch directly to next app.
14291463 var oneWayFlick = true;
14301464 var smallestX = rightEdgeDragArea.width;
14311465 for (var i = 0; i < gesturePoints.length; i++) {
@@ -1437,7 +1471,7 @@ AbstractStage {
14371471 }
14381472
14391473 if (appRepeater.count > 1 &&
1440− (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > units.gu(15))) {
1474+ (oneWayFlick && rightEdgeDragArea.distance > units.gu(2) || rightEdgeDragArea.distance > spreadItem.rightEdgeBreakPoint * spreadItem.width)) {
14411475 var nextStage = appRepeater.itemAt(priv.nextInStack).stage
14421476 for (var i = 0; i < appRepeater.count; i++) {
14431477 if (appRepeater.itemAt(i).stage == nextStage) {