Commit b536e28f authored by Duhoux Pierre-Louis's avatar Duhoux Pierre-Louis

double click left go to previous on first scan / double click right on last next chap

adapt message for click if first scan last scan
delay message on first scan click left / last scan click right to allow time to double click
parent 318852fb
......@@ -1140,10 +1140,18 @@
"message": "This is the latest scan of the chapter. Double tap right key to read next chapter !",
"description": "Alert displayed if trying to go to next scan and last scan"
},
"reader_alert_lastscan_clicked": {
"message": "This is the latest scan of the chapter. Double click on the left part of the screen to read next chapter !",
"description": "Alert displayed if trying to go to next scan and last scan while clicking"
},
"reader_alert_firstscan": {
"message": "This is the first scan of the chapter. Double tap left key to read previous chapter !",
"description": "Alert displayed if trying to go to previous scan and first scan"
},
"reader_alert_firstscan_clicked": {
"message": "This is the first scan of the chapter. Double click on the left part of the screen to read previous chapter !",
"description": "Alert displayed if trying to go to previous scan and first scan while clicking"
},
"reader_alert_firstchapter": {
"message": "This is the first published chapter.",
"description": "Alert displayed if trying to go to previous chapter and first chapter"
......
......@@ -1140,10 +1140,18 @@
"message": "C'est le dernier scan de ce chapitre. Appuyez deux fois rapidement sur la flèche droite pour passer au chapitre suivant !",
"description": "Alert displayed if trying to go to next scan and last scan"
},
"reader_alert_lastscan_clicked": {
"message": "C'est le dernier scan de ce chapitre. Double cliquez sur la partie gauche de l'écran pour passer au chapitre suivant !",
"description": "Alert displayed if trying to go to next scan and last scan while clicking"
},
"reader_alert_firstscan": {
"message": "C'est le premier scan de ce chapitre. Appuyez deux fois rapidement sur la flèche gauche pour passer au chapitre précédent !",
"description": "Alert displayed if trying to go to previous scan and first scan"
},
"reader_alert_firstscan_clicked": {
"message": "C'est le premier scan de ce chapitre. Double cliquez sur la partie gauche de l'écran pour passer au chapitre précédent !",
"description": "Alert displayed if trying to go to previous scan and first scan while clicking"
},
"reader_alert_firstchapter": {
"message": "C'est le premier chapitre publié.",
"description": "Alert displayed if trying to go to previous chapter and first chapter"
......
......@@ -681,7 +681,7 @@
/** Go to next chapter */
goNextChapter() {
if (this.lastChapter) { // display an alert because there is no next chapter
this.$refs.wizdialog.temporary(this.i18n("content_nav_last_chap"))
this.$refs.wizdialog.temporary(this.i18n("content_nav_last_chap"), {important: true})
}
if (!this.nextChapter) return
window.location.href = this.nextChapter
......@@ -690,7 +690,7 @@
goPreviousChapter() {
if (this.selchap === null) return false
if (this.firstChapter) { // display an alert because there is no previous chapter
this.$refs.wizdialog.temporary(this.i18n("reader_alert_firstchapter"))
this.$refs.wizdialog.temporary(this.i18n("reader_alert_firstchapter"), {important: true})
return
}
let cur = this.chapters.findIndex(el => el.url === this.selchap)
......
<template>
<v-container fluid text-xs-center pa-0
:class="{'no-full-chapter': !fullchapter}" @click="pageChange" ref="scancontainer">
:class="{'no-full-chapter': !fullchapter}" @click="pageChange" @dblclick="tryChapterChange" ref="scancontainer">
<!-- Scans -->
<table ref="scantable" class="amr-scan-container" border="0" cellspacing="0" cellpadding="0">
<Page v-for="(scans, i) in pages" :key="i"
......@@ -46,6 +46,7 @@ import Page from "./Page";
import EventBus from "./EventBus";
import { i18nmixin } from "../mixins/i18n-mixin"
import { scroller } from 'vue-scrollto/src/scrollTo'
import util from "./util";
/** Create a custom scroller (alias of $scrollTo method) to enable multiple scrollings (thumbs scroll simultaneously page scroll) */
const thumbsScroller = scroller()
......@@ -183,12 +184,47 @@ export default {
pageChange(e) {
if (this.fullchapter) return
let cur = this.currentPage, n = cur
if (e.clientX >= this.$refs.scancontainer.clientWidth / 2) {
this.goNextScan()
if (cur + 1 < this.pages.length) n = cur + 1
if (n === cur) { // last scan, wait a little before trying to go next scan so if double click, it will be handled
setTimeout(() => this.goNextScan(false, true), 250)
} else {
this.goNextScan(false, true)
}
} else {
this.goPreviousScan()
if (cur - 1 >= 0) n = cur - 1
if (n === cur) { // first scan, wait a little before trying to go next scan so if double click, it will be handled
setTimeout(() => this.goPreviousScan(false, true), 250)
} else {
this.goPreviousScan(false, true)
}
}
},
/**
* Double click on the scans container :
* - if first scan and click left --> go to previous chapter
* - if last scan and click right --> go to next chapter
*/
tryChapterChange(e) {
util.clearSelection()
let cur = this.currentPage, n = cur
if (e.clientX >= this.$refs.scancontainer.clientWidth / 2) {
if (cur + 1 < this.pages.length) n = cur + 1
if (n === cur) {
EventBus.$emit('go-next-chapter')
return
}
} else {
if (cur - 1 >= 0) n = cur - 1
if (n === cur) {
EventBus.$emit('go-previous-chapter')
return
}
}
},
/**
* Determine if a page should be shown.
* Always true if fullChapter mode, just current page if not
......@@ -291,7 +327,7 @@ export default {
}
},
/** Go to next scan */
goNextScan(doubletap) {
goNextScan(doubletap = false, clicked = false) {
let cur = this.currentPage, n = cur
if (cur + 1 < this.pages.length) n = cur + 1
......@@ -304,7 +340,10 @@ export default {
// just change the visibility of current page and next page
if (cur === n) {
// this is latest scan of the chapter
EventBus.$emit('temporary-dialog', { message: this.i18n("reader_alert_lastscan"), duration: 2000})
EventBus.$emit('temporary-dialog', {
message: clicked ? this.i18n("reader_alert_lastscan_clicked") :
this.i18n("reader_alert_lastscan"),
duration: 2000})
return
}
......@@ -326,7 +365,7 @@ export default {
}
},
/** Go to previous scan */
goPreviousScan(doubletap) {
goPreviousScan(doubletap = false, clicked = false) {
let cur = this.currentPage, n = cur
if (cur - 1 >= 0) n = cur - 1
......@@ -339,7 +378,10 @@ export default {
// just change the visibility of current page and previous page
if (cur === n) {
// this is first scan of the chapter
EventBus.$emit('temporary-dialog', { message: this.i18n("reader_alert_firstscan"), duration: 2000})
EventBus.$emit('temporary-dialog', {
message: clicked ? this.i18n("reader_alert_firstscan_clicked") :
this.i18n("reader_alert_firstscan"),
duration: 2000})
return
}
......
Markdown is supported
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