dismiss by scrolling down too

This commit is contained in:
Marco Martin 2015-06-21 22:34:43 -07:00
parent e776e107ae
commit 422695bae1
2 changed files with 37 additions and 9 deletions

View file

@ -69,7 +69,6 @@ Item {
PlasmaComponents.Label { PlasmaComponents.Label {
anchors { anchors {
bottom: parent.bottom bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
left: parent.left left: parent.left
right: parent.right right: parent.right
} }

View file

@ -35,15 +35,26 @@ FullScreenPanel {
property int offset: 0 property int offset: 0
property int overShoot: units.gridUnit * 2 property int overShoot: units.gridUnit * 2
color: Qt.rgba(0, 0, 0, 0.6 * (Math.min(tasksView.contentY + window.height, window.height) / window.height)) color: Qt.rgba(0, 0, 0, 0.6 * Math.min(
(Math.min(tasksView.contentY + tasksView.height, tasksView.height) / tasksView.height),
((tasksView.contentHeight - tasksView.contentY - tasksView.headerItem.height - tasksView.footerItem.height)/tasksView.height)))
function show() { function show() {
if (!visible) {
tasksView.contentY = -tasksView.headerItem.height;
}
visible = true; visible = true;
scrollAnim.from = tasksView.contentY;
scrollAnim.to = 0; scrollAnim.to = 0;
scrollAnim.running = true; scrollAnim.running = true;
} }
function hide() { function hide() {
scrollAnim.to = -tasksView.headerItem.height; scrollAnim.from = tasksView.contentY;
if (tasksView.contentY + tasksView.headerItem.height < tasksView.contentHeight/2) {
scrollAnim.to = -tasksView.headerItem.height;
} else {
scrollAnim.to = tasksView.contentHeight - tasksView.headerItem.height;
}
scrollAnim.running = true; scrollAnim.running = true;
} }
@ -61,6 +72,7 @@ FullScreenPanel {
SequentialAnimation { SequentialAnimation {
id: scrollAnim id: scrollAnim
property alias to: internalAnim.to property alias to: internalAnim.to
property alias from: internalAnim.from
ScriptAction { ScriptAction {
script: window.visible = true; script: window.visible = true;
} }
@ -73,7 +85,7 @@ FullScreenPanel {
} }
ScriptAction { ScriptAction {
script: { script: {
if (tasksView.contentY <= -tasksView.headerItem.height) { if (tasksView.contentY <= -tasksView.headerItem.height || tasksView.contentY >= tasksView.contentHeight - tasksView.headerItem.height) {
window.visible = false; window.visible = false;
} }
} }
@ -86,11 +98,12 @@ FullScreenPanel {
cellWidth: window.width/2 cellWidth: window.width/2
cellHeight: window.height/2 cellHeight: window.height/2
onFlickingChanged: { onFlickingChanged: {
if (!draggingVertically && contentY < -headerItem.height + window.height) { if (!draggingVertically && contentY < -headerItem.height + window.height ||
scrollAnim.to = Math.round(contentY/window.height) * window.height (contentY + footerItem.height) > (contentHeight - footerItem.height - window.height/6*5)) {
scrollAnim.running = true; window.hide();
} }
} }
onDraggingVerticallyChanged: { onDraggingVerticallyChanged: {
if (draggingVertically) { if (draggingVertically) {
return; return;
@ -108,9 +121,21 @@ FullScreenPanel {
contentY < (-headerItem.height + window.height/6*5)) { contentY < (-headerItem.height + window.height/6*5)) {
hide(); hide();
return; return;
}
if (contentY < 0) { //hide by scrolling down
} else if ((contentY + footerItem.height) > (contentHeight - footerItem.height - window.height/6*5)) {
hide();
return;
//show
} else if ((contentY + tasksView.height) > (contentHeight - headerItem.height - footerItem.height) &&
(contentY + tasksView.height) < (contentHeight - headerItem.height - footerItem.height + window.height/6*5)) {
scrollAnim.from = tasksView.contentY;
visible = true;
scrollAnim.to = contentHeight - footerItem.height - tasksView.height*2;
scrollAnim.running = true;
return;
} else if (contentY < 0) {
show(); show();
} }
} }
@ -120,6 +145,10 @@ FullScreenPanel {
width: window.width width: window.width
height: window.height height: window.height
} }
footer: Item {
width: window.width
height: window.height
}
delegate: Task {} delegate: Task {}
displaced: Transition { displaced: Transition {
NumberAnimation { NumberAnimation {