mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-27 14:33:08 +00:00
homescreen: optimise flick container
This commit is contained in:
parent
131c3bd911
commit
c3e3a4e72f
1 changed files with 5 additions and 33 deletions
|
|
@ -26,37 +26,15 @@ Flickable {
|
||||||
|
|
||||||
readonly property real startContentX: contentWidth / 2
|
readonly property real startContentX: contentWidth / 2
|
||||||
readonly property real startContentY: contentHeight / 2
|
readonly property real startContentY: contentHeight / 2
|
||||||
|
|
||||||
property bool positionChangedDueToFlickable: false
|
|
||||||
|
|
||||||
// ensure that flickable is not moving when other sources are changing position
|
|
||||||
Connections {
|
|
||||||
target: root.homeScreenState
|
|
||||||
|
|
||||||
onXPositionChanged: {
|
|
||||||
if (!root.positionChangedDueToFlickable) {
|
|
||||||
root.cancelMovement();
|
|
||||||
}
|
|
||||||
root.positionChangedDueToFlickable = true;
|
|
||||||
}
|
|
||||||
onYPositionChanged: {
|
|
||||||
if (!root.positionChangedDueToFlickable) {
|
|
||||||
root.cancelMovement();
|
|
||||||
}
|
|
||||||
root.positionChangedDueToFlickable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update position from flickable movement
|
// update position from flickable movement
|
||||||
property real oldContentX
|
property real oldContentX
|
||||||
property real oldContentY
|
property real oldContentY
|
||||||
onContentXChanged: {
|
onContentXChanged: {
|
||||||
positionChangedDueToFlickable = true;
|
|
||||||
homeScreenState.updatePositionWithOffset(contentX - oldContentX, 0);
|
homeScreenState.updatePositionWithOffset(contentX - oldContentX, 0);
|
||||||
oldContentX = contentX;
|
oldContentX = contentX;
|
||||||
}
|
}
|
||||||
onContentYChanged: {
|
onContentYChanged: {
|
||||||
positionChangedDueToFlickable = true;
|
|
||||||
homeScreenState.updatePositionWithOffset(0, -(contentY - oldContentY));
|
homeScreenState.updatePositionWithOffset(0, -(contentY - oldContentY));
|
||||||
oldContentY = contentY;
|
oldContentY = contentY;
|
||||||
}
|
}
|
||||||
|
|
@ -75,11 +53,13 @@ Flickable {
|
||||||
|
|
||||||
onDragStarted: homeScreenState.cancelEditModeForItemsRequested()
|
onDragStarted: homeScreenState.cancelEditModeForItemsRequested()
|
||||||
onDragEnded: homeScreenState.cancelEditModeForItemsRequested()
|
onDragEnded: homeScreenState.cancelEditModeForItemsRequested()
|
||||||
onFlickStarted: homeScreenState.cancelEditModeForItemsRequested()
|
onFlickStarted: {
|
||||||
|
homeScreenState.cancelEditModeForItemsRequested();
|
||||||
|
root.cancelFlick();
|
||||||
|
}
|
||||||
|
|
||||||
onDraggingChanged: {
|
onDraggingChanged: {
|
||||||
if (!dragging) {
|
if (!dragging) {
|
||||||
cancelMovement();
|
|
||||||
resetPosition();
|
resetPosition();
|
||||||
if (!homeScreenState.animationsRunning) {
|
if (!homeScreenState.animationsRunning) {
|
||||||
homeScreenState.updateState();
|
homeScreenState.updateState();
|
||||||
|
|
@ -89,15 +69,7 @@ Flickable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelMovement() {
|
|
||||||
root.cancelFlick();
|
|
||||||
|
|
||||||
// HACK: cancelFlick() doesn't seem to cancel flicks...
|
|
||||||
root.flick(-horizontalVelocity, -verticalVelocity);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetPosition() {
|
function resetPosition() {
|
||||||
positionChangedDueToFlickable = true;
|
|
||||||
oldContentX = startContentX;
|
oldContentX = startContentX;
|
||||||
contentX = startContentX;
|
contentX = startContentX;
|
||||||
oldContentY = startContentY;
|
oldContentY = startContentY;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue