diff --git a/containments/homescreen/package/contents/ui/launcher/private/DragGestureHandler.qml b/containments/homescreen/package/contents/ui/launcher/private/DragGestureHandler.qml index ffe88d77..d5d615e5 100644 --- a/containments/homescreen/package/contents/ui/launcher/private/DragGestureHandler.qml +++ b/containments/homescreen/package/contents/ui/launcher/private/DragGestureHandler.qml @@ -15,20 +15,26 @@ DragHandler { xAxis.enabled: enabled property Flickable mainFlickable property Launcher.AppDrawer appDrawer + signal snapPage + enum ScrollDirection { None, Horizontal, Vertical } + property real __initialMainFlickableX property int __scrollDirection: DragGestureHandler.None - onTranslationChanged: {print(translation.x) + onTranslationChanged: { if (active) { if (appDrawer.offset > PlasmaCore.Units.gridUnit) { __scrollDirection = DragGestureHandler.Vertical; + snapPage(); } else if (Math.abs(mainFlickable.contentX - __initialMainFlickableX) > PlasmaCore.Units.gridUnit) { __scrollDirection = DragGestureHandler.Horizontal; + appDrawer.close(); } + if (__scrollDirection !== DragGestureHandler.Horizontal) { appDrawer.offset = -translation.y; } @@ -41,7 +47,9 @@ DragHandler { if (active) { __initialMainFlickableX = mainFlickable.contentX; } else { + __scrollDirection = DragGestureHandler.None; appDrawer.snapDrawerStatus(); + snapPage(); } } } diff --git a/containments/homescreen/package/contents/ui/main.qml b/containments/homescreen/package/contents/ui/main.qml index 1b77b3a0..1cc07f4e 100644 --- a/containments/homescreen/package/contents/ui/main.qml +++ b/containments/homescreen/package/contents/ui/main.qml @@ -67,6 +67,12 @@ Item { plasmoid.nativeInterface.applicationListModel.maxFavoriteCount = Math.max(4, Math.floor(Math.min(width, height) / appletsLayout.cellWidth)); } + function snapPage() { + scrollAnim.running = false; + scrollAnim.to = mainFlickable.width * Math.round(mainFlickable.contentX / mainFlickable.width) + scrollAnim.running = true; + } + //END functions @@ -177,47 +183,14 @@ Item { onContentYChanged: MobileShell.HomeScreenControls.homeScreenPosition = contentY LauncherPrivate.DragGestureHandler { + id: gestureHandler + target: appletsLayout appDrawer: appDrawer mainFlickable: mainFlickable enabled: root.focus && appDrawer.status !== Launcher.AppDrawer.Status.Open && !appletsLayout.editMode && !plasmoid.editMode && !launcherDragManager.active + onSnapPage: root.snapPage(); } -/* - DragHandler { - target: mainFlickable - yAxis.enabled: !appletsLayout.editMode && !plasmoid.editMode && !launcherDragManager.active - xAxis.enabled: yAxis.enabled - enabled: root.focus && appDrawer.status !== Launcher.AppDrawer.Status.Open - property real initialMainFlickableX - enum ScrollDirection { - None, - Horizontal, - Vertical - } - property int scrollDirection: None - onTranslationChanged: {print(translation.x) - if (active) { - if (appDrawer.offset > PlasmaCore.Units.gridUnit) { - scrollDirection = Vertical; - } else if (Math.abs(mainFlickable.contentX - initialMainFlickableX) > PlasmaCore.Units.gridUnit) { - scrollDirection = Horizontal; - } - if (scrollDirection !== Horizontal) { - appDrawer.offset = -translation.y; - } - if (scrollDirection !== Vertical) { - mainFlickable.contentX = Math.max(0, initialMainFlickableX - translation.x); - } - } - } - onActiveChanged: { - if (active) { - initialMainFlickableX = mainFlickable.contentX; - } else { - appDrawer.snapDrawerStatus(); - } - } - } -*/ + NumberAnimation { id: scrollAnim target: mainFlickable @@ -326,7 +299,7 @@ Item { } signal appletsLayoutInteracted -onChildrenRectChanged: print("AAAAAA"+childrenRect.width) + TapHandler { target: mainFlickable enabled: appDrawer.status !== Launcher.AppDrawer.Status.Open @@ -441,20 +414,12 @@ onChildrenRectChanged: print("AAAAAA"+childrenRect.width) } appletsLayout: appletsLayout - DragHandler { + LauncherPrivate.DragGestureHandler { target: favoriteStrip - yAxis.enabled: !appletsLayout.editMode - enabled: root.focus && appDrawer.status !== Launcher.AppDrawer.Status.Open - onTranslationChanged: { - if (active) { - appDrawer.offset = -translation.y - } - } - onActiveChanged: { - if (!active) { - appDrawer.snapDrawerStatus(); - } - } + appDrawer: appDrawer + mainFlickable: mainFlickable + enabled: root.focus && appDrawer.status !== Launcher.AppDrawer.Status.Open && !appletsLayout.editMode && !plasmoid.editMode && !launcherDragManager.active + onSnapPage: root.snapPage(); } TapHandler { target: favoriteStrip