on xenial help sign in
Fix issues dismissing Drawer on large screens

If the user dragged the Drawer open further than necessary, dragging the Drawer closed would take an equal amount of distance to start the closing animation as the original overshoot.

commitc6628ec124ae92db4435a012f9d55fa77ba4ee0f authorDalton Durst <dalton@ubports.com> dateMon 31 May 2021, 11:47 (5 years ago) parent5d5c433
2 files changed+24
qml/Launcher/Drawer.qml+1 tests/qmltests/Launcher/tst_Drawer.qml+23
qml/Launcher/Drawer.qml+1
@@ -202,6 +202,7 @@ FocusScope {
202202 function reset() {
203203 root.draggingHorizontally = false;
204204 handle.active = false;
205+ root.dragDistance = 0;
205206 }
206207
207208 Handle {
tests/qmltests/Launcher/tst_Drawer.qml+23
@@ -421,5 +421,28 @@ StyledItem {
421421
422422 tryCompare(searchField, "focus", false);
423423 }
424+
425+ function test_dragDistanceReset() {
426+ // Regression test: If the user dragged the Drawer open further than
427+ // necessary, dragging the Drawer closed would take an equal amount
428+ // of distance to start the animation as the original overshoot.
429+
430+ var drawer = dragDrawerIntoView();
431+ var dragY = drawer.height / 2;
432+ // Drag the Drawer most of the way closed, then *way* open
433+ mousePress(root, drawer.width - units.gu(1), dragY);
434+ mouseMove(root, 10, dragY, 500);
435+ mouseMove(root, units.gu(100), dragY, 500);
436+ mouseRelease(root, units.gu(100), dragY);
437+
438+ // Ensure the Drawer's margin changes correctly on the next drag closed
439+ mousePress(root, drawer.width - units.gu(1), dragY);
440+ mouseMove(root, 1, dragY);
441+ // If the Drawer's position is within 2gu of hidden, it's probably okay.
442+ tryVerify(function () {return drawer.x < -(drawer.width - units.gu(2))});
443+ // But it should not be completely hidden.
444+ tryCompare(drawer, "visible", true);
445+ mouseRelease(root, 1, dragY);
446+ }
424447 }
425448}