on xenial help sign in
make it more linear
ad62f92Michael Zanetti
qml/Stages/DesktopStage.qml+12−1
@@ -152,6 +152,8 @@ Item {
152 x: spreadMaths.desktopX(index, root.width, spreadFlickable.contentX)
152 x: spreadMaths.desktopX(index, root.width, spreadFlickable.contentX)
153 y: spreadMaths.desktopY(root.height, appDelegate.height)
153 y: spreadMaths.desktopY(root.height, appDelegate.height)
154 angle: spreadMaths.desktopAngle(index, spreadFlickable.contentX)
154 angle: spreadMaths.desktopAngle(index, spreadFlickable.contentX)
155+ itemScale: spreadMaths.desktopScale(root.height, appDelegate.height)
156+ itemScaleOriginY: appDelegate.height;
155 color: "green"
157 color: "green"
156 z: index
158 z: index
157 }
159 }
@@ -169,9 +171,18 @@ Item {
169 }
171 }
170 ]
172 ]
171 property real angle: 0
173 property real angle: 0
174+ property real itemScale: 1
175+ property int itemScaleOriginX: 0
176+ property int itemScaleOriginY: 0
172 transform: [
177 transform: [
178+ Scale {
179+ origin.x: itemScaleOriginX
180+ origin.y: itemScaleOriginY
181+ xScale: itemScale
182+ yScale: itemScale
183+ },
173 Rotation {
184 Rotation {
174− origin { x: 0; y: appDelegate.height / 2 }
185+ origin { x: 0; y: (appDelegate.height / 2) / itemScale }
175 axis { x: 0; y: 1; z: 0 }
186 axis { x: 0; y: 1; z: 0 }
176 angle: appDelegate.angle
187 angle: appDelegate.angle
177 }
188 }
qml/Stages/SpreadMaths.qml+13−11
@@ -5,6 +5,8 @@ QtObject {
5 id: root
5 id: root
6
6
7 function desktopX(index, totalWidth, flickableX) {
7 function desktopX(index, totalWidth, flickableX) {
8+ // Uncomment this to keep linear x movement
9+ // return (totalWidth / 5) * index - flickableX;
8 var distance = totalWidth / 5;
10 var distance = totalWidth / 5;
9 var minX = 0;
11 var minX = 0;
10 var startX = index * distance;
12 var startX = index * distance;
@@ -20,20 +22,20 @@ QtObject {
20 return x;
22 return x;
21 }
23 }
22
24
23− function desktopY(totalHeight, itemHeight) {
25+ function desktopY(sceneHeight, itemHeight) {
24− return (totalHeight - itemHeight) / 2;
26+ return sceneHeight - itemHeight - (sceneHeight * 0.1);
25 }
27 }
26
28
27 function desktopAngle(index, flickableX) {
29 function desktopAngle(index, flickableX) {
28− var startProgress = 0;
30+ return 20;
29− var endProgress = 1;
31+ }
30− var startValue = index * 5;
32+
31− var endValue = 0;
33+ function desktopScale(sceneHeight, itemHeight) {
32− var progress = 1.0 * flickableX / startValue;
34+ var maxHeight = sceneHeight / 2;
33− print("progress for tile", index, ":", startProgress, endProgress, startValue, endValue, progress)
35+ if (itemHeight > maxHeight) {
34− var angle = easingAnimation(startProgress, endProgress, startValue, endValue, progress);
36+ return maxHeight / itemHeight
35− print("resulting angle:", angle)
37+ }
36− return angle;
38+ return 1;
37 }
39 }
38
40
39 function easingAnimation(startProgress, endProgress, startValue, endValue, progress) {
41 function easingAnimation(startProgress, endProgress, startValue, endValue, progress) {