on xenial help sign in
treat leftmost item special and make it fold later to use up all the available screen estate
ec403a5Michael Zanetti
qml/Stages/SpreadMaths.qml+40−25
@@ -35,11 +35,8 @@ Item {
35
35
36 readonly property int contentWidth: flickableWidth - root.margins * 2
36 readonly property int contentWidth: flickableWidth - root.margins * 2
37
37
38− // The y offset we need to add because of scaled tiles in the stacks
39− readonly property int yOffset: -spreadHeight * stackScale / 2
40−
41− readonly property int distance: (flickableContentWidth - (margins * 2) - (foldingAreaWidth * 2)) / totalItems
38+ readonly property int distance: (flickableContentWidth - (margins * 2) - (foldingAreaWidth * 2)) / (totalItems - 2)
42− readonly property int startPos: margins + foldingAreaWidth + itemIndex * distance
39+ readonly property int startPos: margins + foldingAreaWidth + (itemIndex - 1) * distance
43 readonly property int linearX: startPos - flickableProgress * (flickableContentWidth - flickableWidth)
40 readonly property int linearX: startPos - flickableProgress * (flickableContentWidth - flickableWidth)
44
41
45 readonly property int leftFoldingAreaX: margins + foldingAreaWidth
42 readonly property int leftFoldingAreaX: margins + foldingAreaWidth
@@ -51,17 +48,33 @@ Item {
51 readonly property real limitedLeftProgress: Math.min(2, leftFoldingAreaProgress)
48 readonly property real limitedLeftProgress: Math.min(2, leftFoldingAreaProgress)
52 readonly property real limitedRightProgress: Math.min(2, rightFoldingAreaProgress)
49 readonly property real limitedRightProgress: Math.min(2, rightFoldingAreaProgress)
53
50
51+// Label {
52+// anchors { left: parent.left; top: parent.top; topMargin: - 100 }
53+// text: leftFoldingAreaProgress.toFixed(2)
54+// color: "green"
55+// fontSize: "x-large"
56+// }
57+
54 // Output
58 // Output
55 readonly property int animatedX: {
59 readonly property int animatedX: {
56− if (leftFoldingAreaProgress > 4) {
60+ if (leftFoldingAreaProgress > 4) { // Stop it at the edge
57 return margins;
61 return margins;
58 }
62 }
59− if (leftFoldingAreaProgress > 2) {
63+ if (leftFoldingAreaProgress > 2) { // move it slowly through the stack
60 return linearAnimation(2, 4, margins + stackWidth, margins, leftFoldingAreaProgress)
64 return linearAnimation(2, 4, margins + stackWidth, margins, leftFoldingAreaProgress)
61 }
65 }
62− if (leftFoldingAreaProgress > 0) {
66+ if (leftFoldingAreaProgress > 1 && itemIndex == 0) {
67+ // The leftmost runs faster... make it stop before the stack and wait for others
68+ return margins + stackWidth;
69+ }
70+
71+ if (leftFoldingAreaProgress > 0) { // slow it down in a curve
72+ if (itemIndex == 0) { // except if it's the leftmost. that one goes straigt
73+ return linearAnimation(0, 1, leftFoldingAreaX, margins + stackWidth, leftFoldingAreaProgress)
74+ }
63 return linearAnimation(0, 1, leftFoldingAreaX, margins + stackWidth, leftEasing.value)
75 return linearAnimation(0, 1, leftFoldingAreaX, margins + stackWidth, leftEasing.value)
64 }
76 }
77+ // same for the right side stack... mostly... don't need to treat the rightmost special...
65 if (rightFoldingAreaProgress > 4) {
78 if (rightFoldingAreaProgress > 4) {
66 return flickableWidth - margins
79 return flickableWidth - margins
67 }
80 }
@@ -76,23 +89,25 @@ Item {
76 return linearX;
89 return linearX;
77 }
90 }
78
91
79− readonly property int animatedY: sceneHeight - itemHeight - spreadBottomOffset +
92+ readonly property int animatedY: sceneHeight - itemHeight - spreadBottomOffset
80− (limitedLeftProgress > 0 ?
93+
81− 0
82−// linearAnimation(0, 1, yOffset, 0, leftEasing.value)
83− : limitedRightProgress > 0 ?
84− 0
85−// linearAnimation(0, 1, yOffset, 0, rightEasing.value)
86− : 0)
87−
88−
89−
90− readonly property int animatedAngle: limitedLeftProgress > 0 ?
94+ readonly property int animatedAngle: {
95+ if (limitedLeftProgress > 0) {
96+ // Leftmost is special...
97+ if (index == 0) {
98+ if (limitedLeftProgress < 1) {
99+ return unfoldedAngle;
100+ } else {
101+ return linearAnimation(1, 2, unfoldedAngle, leftEndFoldedAngle, limitedLeftProgress)
102+ }
103+ }
91− linearAnimation(0, 2, unfoldedAngle, leftEndFoldedAngle, limitedLeftProgress)
104+ return linearAnimation(0, 2, unfoldedAngle, leftEndFoldedAngle, limitedLeftProgress)
92− : limitedRightProgress > 0 ?
105+ } else if (limitedRightProgress > 0) {
93− linearAnimation(0, 2, unfoldedAngle, rightEndFoldedAngle, limitedRightProgress)
106+ return linearAnimation(0, 2, unfoldedAngle, rightEndFoldedAngle, limitedRightProgress)
107+ } else {
94− : unfoldedAngle
108+ return unfoldedAngle
95−
109+ }
110+ }
96
111
97 readonly property real scale: limitedLeftProgress > 0 ?
112 readonly property real scale: limitedLeftProgress > 0 ?
98 linearAnimation(0, 1, 1, 1 + stackScale, leftEasing.value)
113 linearAnimation(0, 1, 1, 1 + stackScale, leftEasing.value)