better decision on when turn the page

This commit is contained in:
Marco Martin 2012-05-22 11:23:35 +02:00
parent abca7780ad
commit eed0736eb1
2 changed files with 14 additions and 3 deletions

View file

@ -66,7 +66,13 @@ PlasmaComponents.Page {
startX = mouse.screenX
startY = mouse.screenY
}
onPositionChanged: {
if (Math.abs(mouse.x - startX) > width/5) {
delegate.pageSwitchEnabled = true
}
}
onReleased: {
delegate.pageSwitchEnabled = false
if (Math.abs(mouse.screenX - startX) < 20 &&
Math.abs(mouse.screenY - startY) < 20) {
if (resourceBrowser.state == "toolsOpen") {
@ -74,7 +80,10 @@ PlasmaComponents.Page {
} else {
resourceBrowser.state = "toolsOpen"
}
} else if (oldDelegate.visible && delegate.delta != 0 && delegate.doSwitch) {
} else if (oldDelegate.visible && delegate.delta != 0 &&
delegate.doSwitch &&
((incrementing && mouse.x <= width/5) ||
!incrementing && mouse.x >= (width/5)*4)) {
oldDelegate = delegate
delegate = (delegate == delegate1) ? delegate2 : delegate1
switchAnimation.running = true

View file

@ -33,8 +33,10 @@ Item {
//if true when released will switch the delegate
property bool doSwitch: false
property bool pageSwitchEnabled: false
property alias document: mainPage.document
property alias pageNumber: mainPage.pageNumber
property string label: model["label"]
function scale(zoom)
@ -86,7 +88,7 @@ Item {
onContentXChanged: {
if (atXBeginning && contentX < 0) {
root.delta = -1
root.doSwitch = (contentX < -mainFlickable.width/4)
root.doSwitch = (contentX < -mainFlickable.width/6)
} else if (atXEnd) {
root.delta = +1
root.doSwitch = (contentX + mainFlickable.width - contentWidth > mainFlickable.width/4)
@ -98,7 +100,7 @@ Item {
PinchArea {
id: imageMargin
width: Math.max(mainFlickable.width+1, mainPage.width)
width: Math.max(mainFlickable.width + (pageSwitchEnabled ? 1: 0), mainPage.width)
height: Math.max(mainFlickable.height, mainPage.height)
property real startWidth