Cancel sliding panel animations on touch so it's more responsive

This commit is contained in:
Devin Lin 2021-02-17 18:01:14 -05:00 committed by Bhushan Shah
parent 006cb7f865
commit f231b04bdc
2 changed files with 12 additions and 1 deletions

View file

@ -52,14 +52,21 @@ NanoShell.FullScreenOverlay {
}
property int direction: SlidingPanel.MovementDirection.None
function cancelAnimations() {
closeAnim.stop();
openAnim.stop();
}
function open() {
cancelAnimations();
window.showFullScreen();
openAnim.restart();
}
function close() {
cancelAnimations();
closeAnim.restart();
}
function updateState() {
cancelAnimations();
if (window.direction === SlidingPanel.MovementDirection.None) {
if (offset < openThreshold) {
close();
@ -194,7 +201,10 @@ NanoShell.FullScreenOverlay {
contentWidth: window.width
contentHeight: window.height*2
bottomMargin: window.height
onMovementStarted: window.userInteracting = true;
onMovementStarted: {
window.cancelAnimations();
window.userInteracting = true;
}
onFlickStarted: window.userInteracting = true;
onMovementEnded: {
window.userInteracting = false;

View file

@ -265,6 +265,7 @@ Item {
anchors.fill: parent
onPressed: {
slidingPanel.cancelAnimations();
slidingPanel.drawerX = Math.min(Math.max(0, mouse.x - slidingPanel.drawerWidth/2), slidingPanel.width - slidingPanel.drawerWidth)
slidingPanel.userInteracting = true;
oldMouseY = mouse.y;