@@ -44,6 +44,9 @@ SpreadDelegate {
44 property real startDistance: units.gu(5)
44 property real startDistance: units.gu(5)
45 property real endDistance: units.gu(.5)
45 property real endDistance: units.gu(.5)
47+ // Hiding tiles when their progress is negative or reached the maximum
48+ visible: progress >= 0 && progress < 1.7
47 onSelectedChanged: {
50 onSelectedChanged: {
48 if (selected) {
51 if (selected) {
49 priv.snapshot();
52 priv.snapshot();
@@ -106,16 +109,6 @@ SpreadDelegate {
106 selectedTopMarginProgress = topMarginProgress;
109 selectedTopMarginProgress = topMarginProgress;
109− // This calculates how much negative progress there can be if unwinding the spread completely
110− // the progress for each tile starts at 0 when it crosses the right edge, so the later a tile comes in,
111− // the bigger its negativeProgress can be.
112− property real negativeProgress: {
113− if (index == 1 && spreadView.phase < 2) {
116− return -index * spreadView.tileDistance / spreadView.width;
119 function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
112 function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
120 // progress : progressDiff = value : valueDiff => value = progress * valueDiff / progressDiff
113 // progress : progressDiff = value : valueDiff => value = progress * valueDiff / progressDiff
121 return (progress - startProgress) * (endValue - startValue) / (endProgress - startProgress) + startValue;
114 return (progress - startProgress) * (endValue - startValue) / (endProgress - startProgress) + startValue;
@@ -127,22 +120,20 @@ SpreadDelegate {
127 return helperEasingCurve.value * (endValue - startValue) + startValue;
120 return helperEasingCurve.value * (endValue - startValue) + startValue;
130− property real animatedEndDistance: linearAnimation(0, 2, root.endDistance, 0, root.progress)
132 // The following blocks handle the animation of the tile in the spread.
123 // The following blocks handle the animation of the tile in the spread.
133 // At the beginning, each tile is attached at the right edge, outside the screen.
124 // At the beginning, each tile is attached at the right edge, outside the screen.
134 // The progress for each tile starts at 0 and it reaches its end position at a progress of 1.
125 // The progress for each tile starts at 0 and it reaches its end position at a progress of 1.
135− // The first phases are handled special for the first 2 tiles. as we do the alt-tab and snapping in there
126+ // The first phases are handled special for the first 2 tiles. as we do the alt-tab and snapping
136− // Once we reached phase 3, the animation is the same for all tiles.
127+ // in there. Once we reached phase 3, the animation is the same for all tiles.
137− // When a tile is selected, the animation state is snapshotted, and the spreadView is unwound (progress animates
128+ // When a tile is selected, the animation state is snapshotted, and the spreadView is unwound.
138− // back to negativeProgress). All tiles are kept in place and faded out to 0 opacity except
129+ // All tiles are kept in place and faded out to 0 opacity except
139 // the selected tile, which is animated from the snapshotted position to be fullscreen.
130 // the selected tile, which is animated from the snapshotted position to be fullscreen.
141 property real xTranslate: {
132 property real xTranslate: {
142 if (otherSelected) {
133 if (otherSelected) {
143 if (spreadView.phase < 2 && index == 0) {
134 if (spreadView.phase < 2 && index == 0) {
144− return linearAnimation(selectedProgress, negativeProgress,
135+ return linearAnimation(selectedProgress, 0, selectedXTranslate,
145− selectedXTranslate, selectedXTranslate - spreadView.tileDistance, root.progress);
136+ selectedXTranslate - spreadView.tileDistance, root.progress);
148 return selectedXTranslate;
139 return selectedXTranslate;
@@ -160,7 +151,7 @@ SpreadDelegate {
160 // Apply the same animation as with the rest but add spreadView.width to align it with the others.
151 // Apply the same animation as with the rest but add spreadView.width to align it with the others.
161 return -easingCurve.value * spreadView.width + spreadView.width;
152 return -easingCurve.value * spreadView.width + spreadView.width;
162 } else if (priv.isSelected) {
153 } else if (priv.isSelected) {
163− return linearAnimation(selectedProgress, negativeProgress, selectedXTranslate, 0, root.progress);
154+ return linearAnimation(selectedProgress, 0, selectedXTranslate, 0, root.progress);
@@ -177,13 +168,14 @@ SpreadDelegate {
177 if (priv.isSelected) {
168 if (priv.isSelected) {
178 // Distance to left edge
169 // Distance to left edge
179 var targetTranslate = -spreadView.width - ((index - 1) * root.startDistance);
170 var targetTranslate = -spreadView.width - ((index - 1) * root.startDistance);
180− return linearAnimation(selectedProgress, negativeProgress,
171+ return linearAnimation(selectedProgress, 0,
181 selectedXTranslate, targetTranslate, root.progress);
172 selectedXTranslate, targetTranslate, root.progress);
184 // Fix it at the right edge...
175 // Fix it at the right edge...
185 var rightEdgeOffset = -((index - 1) * root.startDistance);
176 var rightEdgeOffset = -((index - 1) * root.startDistance);
186 // ...and use our easing to move them to the left. Stop a bit earlier for each tile
177 // ...and use our easing to move them to the left. Stop a bit earlier for each tile
178+ var animatedEndDistance = linearAnimation(0, 2, root.endDistance, 0, root.progress)
187 return -easingCurve.value * spreadView.width + (index * animatedEndDistance) + rightEdgeOffset;
179 return -easingCurve.value * spreadView.width + (index * animatedEndDistance) + rightEdgeOffset;
@@ -197,7 +189,7 @@ SpreadDelegate {
197 return priv.selectedAngle;
189 return priv.selectedAngle;
199 if (priv.isSelected) {
191 if (priv.isSelected) {
200− return linearAnimation(selectedProgress, negativeProgress, selectedAngle, 0, root.progress);
192+ return linearAnimation(selectedProgress, 0, selectedAngle, 0, root.progress);
202 switch (index) {
194 switch (index) {
@@ -229,7 +221,7 @@ SpreadDelegate {
229 return priv.selectedScale;
221 return priv.selectedScale;
231 if (priv.isSelected) {
223 if (priv.isSelected) {
232− return linearAnimation(selectedProgress, negativeProgress, selectedScale, 1, root.progress);
224+ return linearAnimation(selectedProgress, 0, selectedScale, 1, root.progress);
235 switch (index) {
227 switch (index) {
@@ -274,7 +266,7 @@ SpreadDelegate {
275 property real topMarginProgress: {
267 property real topMarginProgress: {
276 if (priv.isSelected) {
268 if (priv.isSelected) {
277− return linearAnimation(selectedProgress, negativeProgress, selectedTopMarginProgress, 0, root.progress);
269+ return linearAnimation(selectedProgress, 0, selectedTopMarginProgress, 0, root.progress);
280 switch (index) {
272 switch (index) {
@@ -326,7 +318,7 @@ SpreadDelegate {
326 id: easingCurve
318 id: easingCurve
327 type: EasingCurve.OutSine
319 type: EasingCurve.OutSine
328 period: 1 - spreadView.positionMarker2
320 period: 1 - spreadView.positionMarker2
329− progress: root.animatedProgress
321+ progress: root.progress
332 // This is used as a calculation helper to figure values for progress other than the current one
324 // This is used as a calculation helper to figure values for progress other than the current one