on xenial help sign in
Adapt onShiftedContentXChanged to work when the content changes very abruptly

This happens in CI quite a bit

commitd1f7c841e330e1da31fae2087fbda669e2c7da80 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 19 Aug 2016, 10:31 (10 years ago) parent9ffec52
1 file changed+7−5
qml/Stages/TabletStage.qml+7−5
qml/Stages/TabletStage.qml+7−5
@@ -485,8 +485,7 @@ AbstractStage {
485485 return;
486486 }
487487
488− switch (phase) {
489− case 0:
488+ if (phase === 0) {
490489 // the "spreadEnabled" part is because when code does "phase = 0; contentX = -shift" to
491490 // dismiss the spread because spreadEnabled went to false, for some reason, during tests,
492491 // Flickable might jump in and change contentX value back, causing the code below to do
@@ -496,14 +495,17 @@ AbstractStage {
496495 if (root.spreadEnabled && shiftedContentX > width * positionMarker2) {
497496 phase = 1;
498497 }
499− break;
500− case 1:
498+ }
499+
500+ // Do not turn to else if
501+ // Sometimes the animation of shiftedContentX is very fast and we need to jump from phase 0 to 1 to 2
502+ // in the same onShiftedContentXChanged
503+ if (phase === 1) {
501504 if (shiftedContentX < width * positionMarker2) {
502505 phase = 0;
503506 } else if (shiftedContentX >= width * positionMarker4 && !spreadDragArea.dragging) {
504507 phase = 2;
505508 }
506− break;
507509 }
508510 }
509511