diff --git a/qml/pages/ReaderPage.qml b/qml/pages/ReaderPage.qml index 1b5ecaf..b3a67f8 100644 --- a/qml/pages/ReaderPage.qml +++ b/qml/pages/ReaderPage.qml @@ -127,6 +127,22 @@ Page { page.restoring = false } } + + // Paginazione a tap: niente scroll libero. La meta' destra va avanti di + // una pagina, la sinistra indietro. Le fasce superiore e inferiore sono + // lasciate ai menu (PullDown in alto, PushUp in basso). + MouseArea { + id: tapZone + anchors.fill: parent + anchors.topMargin: Theme.itemSizeLarge + anchors.bottomMargin: Theme.itemSizeLarge + Theme.paddingLarge + onClicked: { + if (mouse.x > width / 2) + page.nextPage() + else + page.prevPage() + } + } } BusyIndicator { @@ -220,6 +236,40 @@ Page { loadChapter() } + // pagina successiva: se l'ultima pagina del capitolo, passa al capitolo dopo + function nextPage() { + if (!web.loaded || !page.ready) + return + web.runJavaScript( + "var vh=window.innerHeight;" + + "var cur=Math.floor(window.scrollY/vh);" + + "var max=Math.max(0,document.documentElement.scrollHeight-window.innerHeight);" + + "var target=(cur+1)*vh;" + + "if(target<=max){window.scrollTo(0,target);true}else{false}", + function(hasNext) { + if (hasNext) + readScrollPosition() + else + gotoChapter(page.currentChapter + 1) + }) + } + + // pagina precedente: se la prima del capitolo, torna al capitolo prima + function prevPage() { + if (!web.loaded || !page.ready) + return + web.runJavaScript( + "var vh=window.innerHeight;" + + "var cur=Math.floor(window.scrollY/vh);" + + "if(cur>0){window.scrollTo(0,(cur-1)*vh);true}else{false}", + function(hasPrev) { + if (hasPrev) + readScrollPosition() + else + gotoChapter(page.currentChapter - 1) + }) + } + function fontPx() { return Math.round(16 * page.fontScale * 100) / 100 }