@@ -4,6 +4,7 @@ import Ubuntu.Components 0.1
44
55SpreadDelegate {
66 id: root
7+ clip: true
78
89 property bool selected: false
910 property bool otherSelected: false
@@ -42,12 +43,16 @@ SpreadDelegate {
4243 if (spreadView.stage == 1) {
4344 if (index == 0) {
4445 priv.stage2startTranslate = priv.easingAnimation(0, spreadView.positionMarker4, 0, -spreadView.width, spreadView.positionMarker4) + spreadView.width;
46+ priv.stage2startAngle = priv.easingAnimation(0, spreadView.positionMarker4, root.startAngle, root.endAngle, spreadView.positionMarker4)
47+ priv.stage2startScale = priv.easingAnimation(0, spreadView.positionMarker4, root.startScale, root.endScale, spreadView.positionMarker4)
48+ priv.stage2startTopMarginProgress = priv.linearAnimation(0, 1, 0, 1, spreadView.positionMarker4)
4549 } else if (index == 1) {
4650 // find where the main easing for Tile 1 would be when reaching stage 2
4751 var stage2Progress = spreadView.positionMarker4 - spreadView.tileDistance / spreadView.width;
4852 priv.stage2startTranslate = priv.easingAnimation(0, stage2Progress, 0, -spreadView.width + root.endDistance, stage2Progress);
4953 priv.stage2startAngle = priv.easingAnimation(0, stage2Progress, root.startAngle, root.endAngle, stage2Progress)
5054 priv.stage2startScale = priv.easingAnimation(0, stage2Progress, root.startScale, root.endScale, stage2Progress);
55+ priv.stage2startTopMarginProgress = priv.linearAnimation(0, 1, 0, spreadView.positionMarker4, stage2Progress)
5156 }
5257 }
5358 }
@@ -62,12 +67,14 @@ SpreadDelegate {
6267 property real selectedAngle
6368 property real selectedScale
6469 property real selectedOpacity
70+ property real selectedTopMarginProgress
6571
6672 // Those values are needed as target values for the end of stage 1.
6773 // As they are static values, lets caluclate them once when entering stage 1 instead of calculating them in each animation pass.
6874 property real stage2startTranslate
6975 property real stage2startAngle
7076 property real stage2startScale
77+ property real stage2startTopMarginProgress
7178
7279 function snapshot() {
7380 selectedProgress = root.progress;
@@ -75,6 +82,7 @@ SpreadDelegate {
7582 selectedAngle = angle;
7683 selectedScale = scale;
7784 selectedOpacity = opacity;
85+ selectedTopMarginProgress = topMarginProgress;
7886 }
7987
8088 property real negativeProgress: {
@@ -85,7 +93,7 @@ SpreadDelegate {
8593 }
8694
8795 function linearAnimation(startProgress, endProgress, startValue, endValue, progress) {
88− // progress : progressDiff = value : valueDiff
96+ // progress : progressDiff = value : valueDiff => value = progress * valueDiff / progressDiff
8997 return (progress - startProgress) * (endValue - startValue) / (endProgress - startProgress) + startValue;
9098 }
9199
@@ -147,7 +155,7 @@ SpreadDelegate {
147155 newAngle = linearAnimation(0, spreadView.positionMarker2, 0, root.endAngle * spreadView.snapPosition, root.animatedProgress)
148156 break;
149157 } else if (spreadView.stage == 1) {
150− newAngle = linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, root.endAngle * spreadView.snapPosition, root.endAngle, root.progress)
158+ newAngle = linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, root.endAngle * spreadView.snapPosition, stage2startAngle, root.progress)
151159 break;
152160 }
153161 case 1:
@@ -176,7 +184,7 @@ SpreadDelegate {
176184 newScale = 1;
177185 break
178186 } else if(spreadView.stage == 1) {
179− newScale = linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, 1, root.endScale, root.progress)
187+ newScale = linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, 1, stage2startScale, root.progress)
180188 break;
181189 }
182190 case 1:
@@ -212,6 +220,30 @@ SpreadDelegate {
212220
213221 return 1;
214222 }
223+
224+ property real topMarginProgress: {
225+ if (selected) {
226+ return linearAnimation(selectedProgress, negativeProgress, selectedTopMarginProgress, 0, root.progress);
227+ }
228+
229+ switch (index) {
230+ case 0:
231+ if (spreadView.stage == 0) {
232+ return 0;
233+ } else if (spreadView.stage == 1) {
234+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, 0, priv.stage2startTopMarginProgress, root.progress);
235+ }
236+ break;
237+ case 1:
238+ if (spreadView.stage == 0) {
239+ return 0;
240+ } else if (spreadView.stage == 1) {
241+ return linearAnimation(spreadView.positionMarker2, spreadView.positionMarker4, 0, priv.stage2startTopMarginProgress, root.progress);
242+ }
243+ }
244+
245+ return root.progress;
246+ }
215247 }
216248
217249 transform: [
@@ -230,6 +262,7 @@ SpreadDelegate {
230262 }
231263 ]
232264 opacity: priv.opacity
265+ topMarginProgress: priv.topMarginProgress
233266
234267 EasingCurve {
235268 id: easingCurve