mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
next and prev chapter respect linear=no per #110
This commit is contained in:
parent
4ed8272d41
commit
ae7c84aa8a
9 changed files with 102 additions and 34 deletions
|
@ -2561,19 +2561,36 @@ EPUBJS.Book.prototype.prevPage = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Book.prototype.nextChapter = function() {
|
EPUBJS.Book.prototype.nextChapter = function() {
|
||||||
if(this.spinePos < this.spine.length - 1){
|
if (this.spinePos < this.spine.length - 1) {
|
||||||
this.spinePos += 1;
|
var next = this.spinePos + 1;
|
||||||
return this.displayChapter(this.spinePos);
|
while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') {
|
||||||
|
next++;
|
||||||
|
}
|
||||||
|
if (next < this.spine.length - 1) {
|
||||||
|
this.spinePos = next;
|
||||||
|
return this.displayChapter(this.spinePos);
|
||||||
|
} else {
|
||||||
|
this.trigger("book:atEnd");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.trigger("book:atEnd");
|
this.trigger("book:atEnd");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Book.prototype.prevChapter = function() {
|
EPUBJS.Book.prototype.prevChapter = function() {
|
||||||
if(this.spinePos > 0){
|
if (this.spinePos > 0) {
|
||||||
this.spinePos -= 1;
|
var prev = this.spinePos - 1;
|
||||||
return this.displayChapter(this.spinePos, true);
|
while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') {
|
||||||
|
prev--;
|
||||||
|
}
|
||||||
|
if (prev >= 0) {
|
||||||
|
this.spinePos = prev;
|
||||||
|
return this.displayChapter(this.spinePos, true);
|
||||||
|
} else {
|
||||||
|
this.trigger("book:atStart");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.trigger("book:atStart");
|
this.trigger("book:atStart");
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
4
build/epub.min.js
vendored
4
build/epub.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -2560,19 +2560,36 @@ EPUBJS.Book.prototype.prevPage = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Book.prototype.nextChapter = function() {
|
EPUBJS.Book.prototype.nextChapter = function() {
|
||||||
if(this.spinePos < this.spine.length - 1){
|
if (this.spinePos < this.spine.length - 1) {
|
||||||
this.spinePos += 1;
|
var next = this.spinePos + 1;
|
||||||
return this.displayChapter(this.spinePos);
|
while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') {
|
||||||
|
next++;
|
||||||
|
}
|
||||||
|
if (next < this.spine.length - 1) {
|
||||||
|
this.spinePos = next;
|
||||||
|
return this.displayChapter(this.spinePos);
|
||||||
|
} else {
|
||||||
|
this.trigger("book:atEnd");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.trigger("book:atEnd");
|
this.trigger("book:atEnd");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Book.prototype.prevChapter = function() {
|
EPUBJS.Book.prototype.prevChapter = function() {
|
||||||
if(this.spinePos > 0){
|
if (this.spinePos > 0) {
|
||||||
this.spinePos -= 1;
|
var prev = this.spinePos - 1;
|
||||||
return this.displayChapter(this.spinePos, true);
|
while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') {
|
||||||
|
prev--;
|
||||||
|
}
|
||||||
|
if (prev >= 0) {
|
||||||
|
this.spinePos = prev;
|
||||||
|
return this.displayChapter(this.spinePos, true);
|
||||||
|
} else {
|
||||||
|
this.trigger("book:atStart");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.trigger("book:atStart");
|
this.trigger("book:atStart");
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
31
reader/js/epub.min.js
vendored
31
reader/js/epub.min.js
vendored
|
@ -2561,19 +2561,36 @@ EPUBJS.Book.prototype.prevPage = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Book.prototype.nextChapter = function() {
|
EPUBJS.Book.prototype.nextChapter = function() {
|
||||||
if(this.spinePos < this.spine.length - 1){
|
if (this.spinePos < this.spine.length - 1) {
|
||||||
this.spinePos += 1;
|
var next = this.spinePos + 1;
|
||||||
return this.displayChapter(this.spinePos);
|
while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') {
|
||||||
|
next++;
|
||||||
|
}
|
||||||
|
if (next < this.spine.length - 1) {
|
||||||
|
this.spinePos = next;
|
||||||
|
return this.displayChapter(this.spinePos);
|
||||||
|
} else {
|
||||||
|
this.trigger("book:atEnd");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.trigger("book:atEnd");
|
this.trigger("book:atEnd");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Book.prototype.prevChapter = function() {
|
EPUBJS.Book.prototype.prevChapter = function() {
|
||||||
if(this.spinePos > 0){
|
if (this.spinePos > 0) {
|
||||||
this.spinePos -= 1;
|
var prev = this.spinePos - 1;
|
||||||
return this.displayChapter(this.spinePos, true);
|
while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') {
|
||||||
|
prev--;
|
||||||
|
}
|
||||||
|
if (prev >= 0) {
|
||||||
|
this.spinePos = prev;
|
||||||
|
return this.displayChapter(this.spinePos, true);
|
||||||
|
} else {
|
||||||
|
this.trigger("book:atStart");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.trigger("book:atStart");
|
this.trigger("book:atStart");
|
||||||
}
|
}
|
||||||
|
|
31
src/book.js
31
src/book.js
|
@ -785,19 +785,36 @@ EPUBJS.Book.prototype.prevPage = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Book.prototype.nextChapter = function() {
|
EPUBJS.Book.prototype.nextChapter = function() {
|
||||||
if(this.spinePos < this.spine.length - 1){
|
if (this.spinePos < this.spine.length - 1) {
|
||||||
this.spinePos += 1;
|
var next = this.spinePos + 1;
|
||||||
return this.displayChapter(this.spinePos);
|
while (this.spine[next] && this.spine[next].linear && this.spine[next].linear == 'no') {
|
||||||
|
next++;
|
||||||
|
}
|
||||||
|
if (next < this.spine.length - 1) {
|
||||||
|
this.spinePos = next;
|
||||||
|
return this.displayChapter(this.spinePos);
|
||||||
|
} else {
|
||||||
|
this.trigger("book:atEnd");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.trigger("book:atEnd");
|
this.trigger("book:atEnd");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Book.prototype.prevChapter = function() {
|
EPUBJS.Book.prototype.prevChapter = function() {
|
||||||
if(this.spinePos > 0){
|
if (this.spinePos > 0) {
|
||||||
this.spinePos -= 1;
|
var prev = this.spinePos - 1;
|
||||||
return this.displayChapter(this.spinePos, true);
|
while (this.spine[prev] && this.spine[prev].linear && this.spine[prev].linear == 'no') {
|
||||||
|
prev--;
|
||||||
|
}
|
||||||
|
if (prev >= 0) {
|
||||||
|
this.spinePos = prev;
|
||||||
|
return this.displayChapter(this.spinePos, true);
|
||||||
|
} else {
|
||||||
|
this.trigger("book:atStart");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.trigger("book:atStart");
|
this.trigger("book:atStart");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue