@@ -261,10 +261,12 @@ Item {
262 property real oldProgress: 0
262 property real oldProgress: 0
263 onProgressChanged: {
263 onProgressChanged: {
264+ if (coverFlipDragArea.dragging) {
264− if (oldProgress <= coverFlip.progressMarker1 && progress > coverFlip.progressMarker1) {
265+ if (oldProgress <= coverFlip.progressMarker1 && progress > coverFlip.progressMarker1) {
265− ApplicationManager.focusApplication(ApplicationManager.get(1).appId)
266+ ApplicationManager.move(0, 1)
266− } else if (oldProgress >= coverFlip.progressMarker1 && progress <= coverFlip.progressMarker1) {
267+ } else if (oldProgress >= coverFlip.progressMarker1 && progress <= coverFlip.progressMarker1) {
267− ApplicationManager.focusApplication(ApplicationManager.get(1).appId)
268+ ApplicationManager.move(0, 1)
269 oldProgress = progress;
271 oldProgress = progress;
@@ -272,14 +274,20 @@ Item {
272 function snap() {
274 function snap() {
273 if (coverFlip.progress < 0.25) {
275 if (coverFlip.progress < 0.25) {
274 snapAnimation.targetContentX = 0
276 snapAnimation.targetContentX = 0
277+ snapAnimation.targetAppId = ApplicationManager.get(0).appId;
278+ } else if (coverFlip.progress < coverFlip.progressMarker1) {
279+ snapAnimation.targetContentX = root.width * coverFlip.progressMarker1
280+ snapAnimation.targetAppId = ApplicationManager.get(1).appId;
275 } else if (coverFlip.progress < 0.6) {
281 } else if (coverFlip.progress < 0.6) {
276 snapAnimation.targetContentX = root.width * coverFlip.progressMarker1
282 snapAnimation.targetContentX = root.width * coverFlip.progressMarker1
283+ snapAnimation.targetAppId = ApplicationManager.get(0).appId;
278 if (ApplicationManager.count == 3) {
285 if (ApplicationManager.count == 3) {
279 snapAnimation.targetContentX = root.width * .8;
286 snapAnimation.targetContentX = root.width * .8;
281 snapAnimation.targetContentX = root.width * .9;
288 snapAnimation.targetContentX = root.width * .9;
290+ snapAnimation.targetAppId = "";
284 snapAnimation.start();
292 snapAnimation.start();
@@ -291,6 +299,7 @@ Item {
291 SequentialAnimation {
299 SequentialAnimation {
292 id: snapAnimation
300 id: snapAnimation
293 property var targetContentX
301 property var targetContentX
302+ property var targetAppId
295 UbuntuNumberAnimation {
304 UbuntuNumberAnimation {
296 target: coverFlickable
305 target: coverFlickable
@@ -302,6 +311,9 @@ Item {
302 if (snapAnimation.targetContentX == root.width * coverFlip.progressMarker1) {
311 if (snapAnimation.targetContentX == root.width * coverFlip.progressMarker1) {
303 coverFlickable.contentX = 0;
312 coverFlickable.contentX = 0;
314+ if (snapAnimation.targetAppId) {
315+ ApplicationManager.focusApplication(snapAnimation.targetAppId);
@@ -332,6 +344,7 @@ Item {
332 // We need to remember some values when app is selected to be able to animate it to the foreground
344 // We need to remember some values when app is selected to be able to animate it to the foreground
333 property real selectedXTranslation: 0
345 property real selectedXTranslation: 0
334 property real selectedTranslatedProgress: 0
346 property real selectedTranslatedProgress: 0
347+ property real selectedProgress: 0
335 property real selectedAngle: 0
348 property real selectedAngle: 0
336 property real selectedXScale: 0
349 property real selectedXScale: 0
@@ -339,8 +352,10 @@ Item {
339 appImage.selectedXTranslation = appImage.xTranslation;
352 appImage.selectedXTranslation = appImage.xTranslation;
340 appImage.selectedAngle = appImage.angle;
353 appImage.selectedAngle = appImage.angle;
341 appImage.selectedXScale = appImage.xScale;
354 appImage.selectedXScale = appImage.xScale;
342− appImage.selectedTranslatedProgress = appImage.translatedProgress;
355+ appImage.selectedTranslatedProgress = appImage.translatedProgress - coverFlip.progressMarker1;
356+ appImage.selectedProgress = appImage.progress - coverFlip.progressMarker1;
343 appImage.isSelected = true;
357 appImage.isSelected = true;
358+ switchToAppAnimation.targetContentX = coverFlip.progressMarker1 * root.width
344 switchToAppAnimation.start();
359 switchToAppAnimation.start();
@@ -370,14 +385,18 @@ Item {
371 if (appImage.progress > coverFlip.progressMarker1) {
386 if (appImage.progress > coverFlip.progressMarker1) {
372 xTranslate = xTranslateEasing.value * xTranslateEasing.period;
387 xTranslate = xTranslateEasing.value * xTranslateEasing.period;
388+ if (appImage.isSelected) {
389+ var translateDiff = root.width * index + appImage.selectedXTranslation
390+ var progressDiff = appImage.selectedProgress
391+ var progress = progressDiff - (appImage.progress - coverFlip.progressMarker1);
392+ // progress : progressDiff = translate : translateDiff
393+ var newTranslate = progress * translateDiff / progressDiff;
395+ xTranslate = appImage.selectedXTranslation - newTranslate;
376− if (appImage.isSelected) {
377− var newTranslate = selectedXTranslateEasing.value * selectedXTranslateEasing.period
378− xTranslate = appImage.selectedXTranslation + newTranslate;
381 return xTranslate;
400 return xTranslate;
@@ -416,12 +435,17 @@ Item {
416 // make sure we stop at the left screen edge
435 // make sure we stop at the left screen edge
417 newAngle = Math.max(newAngle, coverFlip.endAngle);
436 newAngle = Math.max(newAngle, coverFlip.endAngle);
420− if (appImage.isSelected) {
438+ if (appImage.isSelected) {
421− var selectedAngleTranslate = selectedAngleEasing.value * selectedAngleEasing.period
439+// var selectedAngleTranslate = selectedAngleEasing.value * selectedAngleEasing.period
422− newAngle = appImage.selectedAngle - selectedAngleTranslate;
440+ var angleDiff = appImage.selectedAngle
423− }
441+ var progressDiff = appImage.selectedProgress
442+ var progress = progressDiff - (appImage.progress - coverFlip.progressMarker1);
443+ // progress : progressDiff = angle : angleDiff
444+ var selectedAngleTranslate = progress * angleDiff / progressDiff;
446+ newAngle = appImage.selectedAngle - selectedAngleTranslate;
425 return newAngle;
449 return newAngle;
@@ -448,51 +472,37 @@ Item {
448 // Intentionally no break
472 // Intentionally no break
450 scale = coverFlip.maxScale - scaleEasing.value * scaleEasing.period;
474 scale = coverFlip.maxScale - scaleEasing.value * scaleEasing.period;
452− if (appImage.isSelected) {
475+ if (appImage.isSelected) {
453− var selectedScaleTranslate = selectedScaleEasing.value * selectedScaleEasing.period
476+ var scaleDiff = -(1 - appImage.selectedXScale)
477+ var progressDiff = appImage.selectedProgress
478+ var progress = progressDiff - (appImage.progress - coverFlip.progressMarker1);
479+ // progress : progressDiff = angle : angleDiff
480+ var selectedScaleTranslate = progress * scaleDiff / progressDiff;
454− scale = appImage.selectedXScale + selectedScaleTranslate;
482+ scale = appImage.selectedXScale - selectedScaleTranslate;
456 return Math.min(coverFlip.maxScale, Math.max(coverFlip.minScale, scale));
485 return Math.min(coverFlip.maxScale, Math.max(coverFlip.minScale, scale));
460 EasingCurve {
488 EasingCurve {
461 id: xTranslateEasing
489 id: xTranslateEasing
462 type: EasingCurve.OutQuad
490 type: EasingCurve.OutQuad
463 period: index * -width
491 period: index * -width
464 progress: appImage.translatedProgress
492 progress: appImage.translatedProgress
467− id: selectedXTranslateEasing
468− type: EasingCurve.Linear
469− period: xTranslateEasing.period - appImage.selectedXTranslation
470− progress: appImage.selectedTranslatedProgress - xTranslateEasing.progress
472 EasingCurve {
494 EasingCurve {
473 id: angleEasing
495 id: angleEasing
474 type: EasingCurve.InQuad
496 type: EasingCurve.InQuad
475 period: coverFlip.startAngle - coverFlip.endAngle
497 period: coverFlip.startAngle - coverFlip.endAngle
476 progress: appImage.translatedProgress
498 progress: appImage.translatedProgress
479− id: selectedAngleEasing
480− type: EasingCurve.Linear
481− period: appImage.selectedAngle
482− progress: appImage.selectedTranslatedProgress - angleEasing.progress
484 EasingCurve {
500 EasingCurve {
485 id: scaleEasing
501 id: scaleEasing
486 type: EasingCurve.Linear
502 type: EasingCurve.Linear
487 period: coverFlip.maxScale - coverFlip.minScale
503 period: coverFlip.maxScale - coverFlip.minScale
488 progress: appImage.translatedProgress
504 progress: appImage.translatedProgress
491− id: selectedScaleEasing
492− type: EasingCurve.Linear
493− period: 1 - appImage.selectedXScale
494− progress: appImage.selectedTranslatedProgress - scaleEasing.progress
497 transform: [
507 transform: [
498 Rotation {
508 Rotation {
@@ -520,8 +530,9 @@ Item {
521 SequentialAnimation {
531 SequentialAnimation {
522 id: switchToAppAnimation
532 id: switchToAppAnimation
533+ property int targetContentX
523 ParallelAnimation {
534 ParallelAnimation {
524− UbuntuNumberAnimation { target: coverFlickable; property: "contentX"; to: 0}
535+ UbuntuNumberAnimation { target: coverFlickable; property: "contentX"; to: switchToAppAnimation.targetContentX }
526 ScriptAction {
537 ScriptAction {
527 script: {
538 script: {