paginar 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +22 -13
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/composables/usePagination.js +22 -13
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "A flipping page web component for reading long texts on the brower",
|
|
5
5
|
"main": "dist/index.es.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.5",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/educkf/paginar.git"
|
|
@@ -8,7 +8,8 @@ import useTextContent from './useTextContent'
|
|
|
8
8
|
const state = reactive({
|
|
9
9
|
currentPage: 1,
|
|
10
10
|
nextTry: 0,
|
|
11
|
-
prevTry: 0
|
|
11
|
+
prevTry: 0,
|
|
12
|
+
willRedirect: false
|
|
12
13
|
})
|
|
13
14
|
|
|
14
15
|
const currentPage = computed(() => state.currentPage)
|
|
@@ -44,20 +45,24 @@ watch(totalPages, () => {
|
|
|
44
45
|
})
|
|
45
46
|
|
|
46
47
|
// navigate by increase/decrease value
|
|
47
|
-
function next() {
|
|
48
|
+
function next(usingScroll = false) {
|
|
48
49
|
if (!useReaderSettings.blocked.value) {
|
|
49
50
|
if ((state.currentPage + 1) <= totalPages.value) {
|
|
50
51
|
state.currentPage = state.currentPage + 1
|
|
51
52
|
} else {
|
|
52
53
|
// prevent going too fast to next chapter on
|
|
53
54
|
// stronger scroll
|
|
54
|
-
if (state.nextTry < 4) {
|
|
55
|
+
if (usingScroll && state.nextTry < 4) {
|
|
55
56
|
state.nextTry += 1
|
|
56
57
|
return
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
if (
|
|
60
|
-
|
|
59
|
+
|
|
60
|
+
if (state.willRedirect === false) {
|
|
61
|
+
const context = useTextContent.context.value
|
|
62
|
+
if (context.surround?.after) {
|
|
63
|
+
window.location.href = context.surround.after.link + (`?origin=prev`)
|
|
64
|
+
state.willRedirect = true
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
}
|
|
@@ -69,26 +74,30 @@ onKeyStroke('ArrowRight', (e) => {
|
|
|
69
74
|
|
|
70
75
|
function onWheel(event) {
|
|
71
76
|
if (event.wheelDelta < 0) {
|
|
72
|
-
next()
|
|
77
|
+
next(true)
|
|
73
78
|
} else {
|
|
74
|
-
prev()
|
|
79
|
+
prev(true)
|
|
75
80
|
}
|
|
76
81
|
};
|
|
77
82
|
|
|
78
|
-
function prev() {
|
|
83
|
+
function prev(usingScroll = false) {
|
|
79
84
|
if (!useReaderSettings.blocked.value) {
|
|
80
85
|
if ((state.currentPage - 1) > 0) {
|
|
81
86
|
state.currentPage = state.currentPage - 1
|
|
82
87
|
} else {
|
|
83
88
|
// prevent going too fast to prev chapter on
|
|
84
89
|
// stronger scroll
|
|
85
|
-
if (state.prevTry < 4) {
|
|
90
|
+
if (usingScroll && state.prevTry < 4) {
|
|
86
91
|
state.prevTry += 1
|
|
87
92
|
return
|
|
88
93
|
}
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
94
|
+
|
|
95
|
+
if (state.willRedirect === false) {
|
|
96
|
+
const context = useTextContent.context.value
|
|
97
|
+
if (context.surround?.before) {
|
|
98
|
+
window.location.href = context.surround.before.link + (`?origin=next`)
|
|
99
|
+
}
|
|
100
|
+
state.willRedirect = true
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
103
|
}
|