on xenial help sign in
Adapt onShiftedContentXChanged to work when the content changes very abruptly
fb89b4aAlbert Astals Cid
qml/Stages/TabletStage.qml+7−5
@@ -485,8 +485,7 @@ AbstractStage {
485 return;
485 return;
486 }
486 }
487
487
488− switch (phase) {
488+ if (phase === 0) {
489− case 0:
490 // the "spreadEnabled" part is because when code does "phase = 0; contentX = -shift" to
489 // the "spreadEnabled" part is because when code does "phase = 0; contentX = -shift" to
491 // dismiss the spread because spreadEnabled went to false, for some reason, during tests,
490 // dismiss the spread because spreadEnabled went to false, for some reason, during tests,
492 // Flickable might jump in and change contentX value back, causing the code below to do
491 // Flickable might jump in and change contentX value back, causing the code below to do
@@ -496,14 +495,17 @@ AbstractStage {
496 if (root.spreadEnabled && shiftedContentX > width * positionMarker2) {
495 if (root.spreadEnabled && shiftedContentX > width * positionMarker2) {
497 phase = 1;
496 phase = 1;
498 }
497 }
499− break;
498+ }
500− case 1:
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) {
501 if (shiftedContentX < width * positionMarker2) {
504 if (shiftedContentX < width * positionMarker2) {
502 phase = 0;
505 phase = 0;
503 } else if (shiftedContentX >= width * positionMarker4 && !spreadDragArea.dragging) {
506 } else if (shiftedContentX >= width * positionMarker4 && !spreadDragArea.dragging) {
504 phase = 2;
507 phase = 2;
505 }
508 }
506− break;
507 }
509 }
508 }
510 }
509
511