Fix wonky behaviour of FooterBar when resizing and PlayerControls are open

This commit is contained in:
Bart De Vries 2021-04-27 21:46:43 +02:00
parent 02e92f9a8f
commit 9ebc6ecb7e

View File

@ -1,4 +1,5 @@
/** /**
* SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com>
* SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be> * SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be>
* *
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
@ -48,25 +49,40 @@ Flickable {
toClose.stop(); toClose.stop();
propagateComposedEvents = true; propagateComposedEvents = true;
} }
onReleased: footerBar.resetToBounds() onReleased: footerBar.resetToBoundsOnFlick()
} }
function resetToBounds() { function resetToBoundsOnFlick() {
if (!atYBeginning && !atYEnd) { if (!atYBeginning || !atYEnd) {
if (footerBar.verticalVelocity > 0) { if (footerBar.verticalVelocity > 0) {
toOpen.restart(); toOpen.restart();
} else if (footerBar.verticalVelocity < 0) { } else if (footerBar.verticalVelocity < 0) {
toClose.restart(); toClose.restart();
} else { // i.e. when verticalVelocity === 0
if (contentY > contentHeight / 4) {
toOpen.restart();
} else {
toClose.restart();
}
} }
} }
} }
function resetToBoundsOnResize() {
if (contentY > contentHeight / 4) {
contentY = contentHeight / 2;
} else {
contentY = 0;
}
}
onMovementStarted: { onMovementStarted: {
toOpen.stop(); toOpen.stop();
toClose.stop(); toClose.stop();
} }
onFlickStarted: resetToBounds() onFlickStarted: resetToBoundsOnFlick()
onMovementEnded: resetToBounds() onMovementEnded: resetToBoundsOnFlick()
onHeightChanged: resetToBoundsOnResize()
Item { Item {
id: background id: background