Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Commit f51d278

Browse files
committed
Validate input index before flipping page
1 parent 4a7439a commit f51d278

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

public/js/reader.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ const readerComponent = () => {
101101
*/
102102
flipPage(isNext) {
103103
const idx = parseInt(this.curItem.id);
104-
const delta = isNext ? 1 : -1;
105-
const newIdx = idx + delta;
104+
const newIdx = idx + (isNext ? 1 : -1);
105+
106+
if (newIdx <= 0 || newIdx > this.items.length) return;
106107

107108
this.toPage(newIdx);
108109

0 commit comments

Comments
 (0)