Commit 131c3bd9 authored by Yari Polla's avatar Yari Polla
Browse files

taskswitcher/lockscreen: trim flick containers and optimise

parent a173cf9b
......@@ -19,36 +19,15 @@ Flickable {
required property var taskSwitcherState
// we use flickable solely for capturing flicks, not positioning elements
contentWidth: width + 99999
contentWidth: width * tasksCount
contentHeight: height
contentX: startContentX
readonly property real startContentX: contentWidth / 2
property bool positionChangedDueToFlickable: false
// ensure that flickable is not moving when other sources are changing position
Connections {
target: root.taskSwitcherState
readonly property real startContentX: 0
onXPositionChanged: {
if (!root.positionChangedDueToFlickable) {
root.cancelMovement();
}
root.positionChangedDueToFlickable = true;
}
onYPositionChanged: {
if (!root.positionChangedDueToFlickable) {
root.cancelMovement();
}
root.positionChangedDueToFlickable = true;
}
}
// update position from horizontal flickable movement
property real oldContentX
onContentXChanged: {
positionChangedDueToFlickable = true;
taskSwitcherState.xPosition += contentX - oldContentX;
oldContentX = contentX;
}
......@@ -58,6 +37,10 @@ Flickable {
resetPosition();
taskSwitcherState.updateState();
}
onFlickStarted: {
root.cancelFlick();
}
onFlickEnded: {
resetPosition();
taskSwitcherState.updateState();
......@@ -65,7 +48,6 @@ Flickable {
onDraggingChanged: {
if (!dragging) {
cancelMovement();
resetPosition();
taskSwitcherState.updateState();
} else {
......@@ -73,15 +55,7 @@ Flickable {
}
}
function cancelMovement() {
root.cancelFlick();
// HACK: cancelFlick() doesn't seem to cancel flicks...
root.flick(-horizontalVelocity, 0);
}
function resetPosition() {
positionChangedDueToFlickable = true;
oldContentX = startContentX;
contentX = startContentX;
}
......
......@@ -49,13 +49,12 @@ Flickable {
// we use flickable solely for capturing flicks, not positioning elements
contentWidth: width
contentHeight: height + 99999
contentHeight: height * 2
contentX: 0
contentY: startContentY
readonly property real startContentY: contentHeight / 2
property bool positionChangedDueToFlickable: false
property int oldPosition: position
property bool movingUp: false
......@@ -63,18 +62,11 @@ Flickable {
onPositionChanged: {
movingUp = oldPosition <= position;
oldPosition = position;
// ensure that flickable is not moving when other sources are changing position
if (!positionChangedDueToFlickable) {
cancelMovement();
}
positionChangedDueToFlickable = true;
}
// update position from flickable movement
property real oldContentY
onContentYChanged: {
positionChangedDueToFlickable = true;
position = Math.max(0, Math.min(keypadHeight, position + (contentY - oldContentY)));
oldContentY = contentY;
}
......@@ -86,11 +78,12 @@ Flickable {
}
resetPosition();
}
onFlickStarted: root.cancelFlick()
onFlickEnded: resetPosition();
onDraggingChanged: {
if (!dragging) {
cancelMovement();
resetPosition();
if (!positionAnim.running) {
root.updateState();
......@@ -100,15 +93,7 @@ Flickable {
}
}
function cancelMovement() {
root.cancelFlick();
// HACK: cancelFlick() doesn't seem to cancel flicks...
root.flick(-horizontalVelocity, -verticalVelocity);
}
function resetPosition() {
positionChangedDueToFlickable = true;
oldContentY = startContentY;
contentY = startContentY;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment