fix the horizontal or vertical scroll decision

This commit is contained in:
Marco Martin 2021-04-08 14:44:09 +02:00
parent c3959d056d
commit d7af742066

View file

@ -31,28 +31,35 @@ DragHandler {
property int __scrollDirection: DragGestureHandler.None property int __scrollDirection: DragGestureHandler.None
onTranslationChanged: { onTranslationChanged: {
if (active) { if (active) {
if (__scrollDirection === DragGestureHandler.None) {
if (root.appDrawer.offset > PlasmaCore.Units.gridUnit) { if (root.appDrawer.offset > PlasmaCore.Units.gridUnit) {
__scrollDirection = DragGestureHandler.Vertical; __scrollDirection = DragGestureHandler.Vertical;
snapPage(); snapPage();
} else if (mainFlickable.contentX - __initialMainFlickableX > PlasmaCore.Units.gridUnit) { } else if (mainFlickable.contentX - __initialMainFlickableX > PlasmaCore.Units.gridUnit) {
__scrollDirection = DragGestureHandler.Right; __scrollDirection = DragGestureHandler.Right;
root.appDrawer.close(); root.appDrawer.close();
} else if (__initialMainFlickableX - mainFlickable.contentX > PlasmaCore.Units.gridUnit) { } else if (__initialMainFlickableX - mainFlickable.contentX > PlasmaCore.Units.gridUnit) {
__scrollDirection = DragGestureHandler.Left; __scrollDirection = DragGestureHandler.Left;
root.appDrawer.close(); root.appDrawer.close();
} }
}
if (__scrollDirection !== DragGestureHandler.Left || __scrollDirection !== DragGestureHandler.Right) { if (__scrollDirection !== DragGestureHandler.Left && __scrollDirection !== DragGestureHandler.Right) {
root.appDrawer.offset = -translation.y; root.appDrawer.offset = -translation.y;
} }
if (__scrollDirection !== DragGestureHandler.Vertical) { if (__scrollDirection !== DragGestureHandler.Vertical) {
let newContentX = Math.min((mainFlickable.width * mainFlickable.totalPages) - mainFlickable.width, Math.max(0, __initialMainFlickableX - translation.x)); let newContentX = Math.min((mainFlickable.width * mainFlickable.totalPages) - mainFlickable.width, Math.max(0, __initialMainFlickableX - translation.x));
if (__scrollDirection !== DragGestureHandler.None) {
if (mainFlickable.contentX < newContentX) { if (mainFlickable.contentX < newContentX) {
__scrollDirection = DragGestureHandler.Right; __scrollDirection = DragGestureHandler.Right;
} else { } else {
__scrollDirection = DragGestureHandler.Left; __scrollDirection = DragGestureHandler.Left;
} }
}
mainFlickable.contentX = newContentX; mainFlickable.contentX = newContentX;
} }