manage the case of appDrawer not present

This commit is contained in:
Marco Martin 2021-05-05 16:46:54 +02:00
parent 77291587bd
commit fb920a3f9f
2 changed files with 21 additions and 17 deletions

View file

@ -33,11 +33,11 @@ Flickable {
property Item footer
property alias dragGestureEnabled: gestureHandler.enabled
opacity: 1 - appDrawer.openFactor
opacity: appDrawer ? 1 - appDrawer.openFactor : 1
transform: Translate {
y: -mainFlickable.height/10 * appDrawer.openFactor
y: appDrawer ? -mainFlickable.height/10 * appDrawer.openFactor : 0
}
scale: (3 - appDrawer.openFactor) /3
scale: appDrawer ? (3 - appDrawer.openFactor) /3 : 1
clip: true
property bool showAddPageIndicator: false

View file

@ -31,6 +31,7 @@ DragHandler {
property int __scrollDirection: DragGestureHandler.None
onTranslationChanged: {
if (active) {
if (root.appDrawer) {
if (__scrollDirection === DragGestureHandler.None) {
if (root.appDrawer.offset > PlasmaCore.Units.gridUnit) {
@ -50,6 +51,7 @@ DragHandler {
if (__scrollDirection !== DragGestureHandler.Left && __scrollDirection !== DragGestureHandler.Right) {
root.appDrawer.offset = -translation.y;
}
}
if (__scrollDirection !== DragGestureHandler.Vertical) {
let newContentX = Math.min((mainFlickable.width * mainFlickable.totalPages) - mainFlickable.width, Math.max(0, __initialMainFlickableX - translation.x));
@ -69,7 +71,9 @@ DragHandler {
if (active) {
__initialMainFlickableX = mainFlickable.contentX;
} else {
if (root.appDrawer) {
root.appDrawer.snapDrawerStatus();
}
if (__scrollDirection === DragGestureHandler.Left && (__initialMainFlickableX - mainFlickable.contentX > PlasmaCore.Units.gridUnit * 5)) {
snapPrevPage();
} else if (__scrollDirection === DragGestureHandler.Right && (mainFlickable.contentX - __initialMainFlickableX > PlasmaCore.Units.gridUnit * 5)) {