on xenial help sign in
make it more linear
commitad62f92e3acf2908f2a6ee2e87d618665e97f943 authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 18 Mar 2015, 17:21 (12 years ago) parent535d849
2 files changed+25−12
qml/Stages/DesktopStage.qml+12−1 qml/Stages/SpreadMaths.qml+13−11
qml/Stages/DesktopStage.qml+12−1
@@ -152,6 +152,8 @@ Item {
152152 x: spreadMaths.desktopX(index, root.width, spreadFlickable.contentX)
153153 y: spreadMaths.desktopY(root.height, appDelegate.height)
154154 angle: spreadMaths.desktopAngle(index, spreadFlickable.contentX)
155+ itemScale: spreadMaths.desktopScale(root.height, appDelegate.height)
156+ itemScaleOriginY: appDelegate.height;
155157 color: "green"
156158 z: index
157159 }
@@ -169,9 +171,18 @@ Item {
169171 }
170172 ]
171173 property real angle: 0
174+ property real itemScale: 1
175+ property int itemScaleOriginX: 0
176+ property int itemScaleOriginY: 0
172177 transform: [
178+ Scale {
179+ origin.x: itemScaleOriginX
180+ origin.y: itemScaleOriginY
181+ xScale: itemScale
182+ yScale: itemScale
183+ },
173184 Rotation {
174− origin { x: 0; y: appDelegate.height / 2 }
185+ origin { x: 0; y: (appDelegate.height / 2) / itemScale }
175186 axis { x: 0; y: 1; z: 0 }
176187 angle: appDelegate.angle
177188 }
qml/Stages/SpreadMaths.qml+13−11
@@ -5,6 +5,8 @@ QtObject {
55 id: root
66
77 function desktopX(index, totalWidth, flickableX) {
8+ // Uncomment this to keep linear x movement
9+ // return (totalWidth / 5) * index - flickableX;
810 var distance = totalWidth / 5;
911 var minX = 0;
1012 var startX = index * distance;
@@ -20,20 +22,20 @@ QtObject {
2022 return x;
2123 }
2224
23− function desktopY(totalHeight, itemHeight) {
24− return (totalHeight - itemHeight) / 2;
25+ function desktopY(sceneHeight, itemHeight) {
26+ return sceneHeight - itemHeight - (sceneHeight * 0.1);
2527 }
2628
2729 function desktopAngle(index, flickableX) {
28− var startProgress = 0;
29− var endProgress = 1;
30− var startValue = index * 5;
31− var endValue = 0;
32− var progress = 1.0 * flickableX / startValue;
33− print("progress for tile", index, ":", startProgress, endProgress, startValue, endValue, progress)
34− var angle = easingAnimation(startProgress, endProgress, startValue, endValue, progress);
35− print("resulting angle:", angle)
36− return angle;
30+ return 20;
31+ }
32+
33+ function desktopScale(sceneHeight, itemHeight) {
34+ var maxHeight = sceneHeight / 2;
35+ if (itemHeight > maxHeight) {
36+ return maxHeight / itemHeight
37+ }
38+ return 1;
3739 }
3840
3941 function easingAnimation(startProgress, endProgress, startValue, endValue, progress) {