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

View file

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