mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
save page position
This commit is contained in:
parent
7c15cec459
commit
954aba9627
3 changed files with 24 additions and 3 deletions
|
@ -96,7 +96,7 @@ FP.Book.prototype.start = function(bookPath){
|
|||
}
|
||||
}
|
||||
|
||||
if(!this.isSaved(true)){
|
||||
if(!this.isSaved()){
|
||||
|
||||
if(!this.online) {
|
||||
console.error("Not Online");
|
||||
|
@ -154,9 +154,12 @@ FP.Book.prototype.isSaved = function(force) {
|
|||
localStorage.setItem("fpjs-version", FP.VERSION);
|
||||
|
||||
localStorage.setItem("bookPath", this.bookPath);
|
||||
localStorage.setItem("spinePos", 0);
|
||||
localStorage.setItem("stored", 0);
|
||||
|
||||
localStorage.setItem("spinePos", 0);
|
||||
localStorage.setItem("chapterPos", 0);
|
||||
localStorage.setItem("displayedPages", 0);
|
||||
|
||||
this.spinePos = 0;
|
||||
this.stored = 0;
|
||||
|
||||
|
@ -177,6 +180,10 @@ FP.Book.prototype.isSaved = function(force) {
|
|||
this.spineIndexByURL = JSON.parse(localStorage.getItem("spineIndexByURL"));
|
||||
this.toc = JSON.parse(localStorage.getItem("toc"));
|
||||
|
||||
//-- Get previous page
|
||||
this.prevChapterPos = parseInt(localStorage.getItem("chapterPos"));
|
||||
this.prevDisplayedPages = parseInt(localStorage.getItem("displayedPages"));
|
||||
|
||||
//-- Check that retrieved object aren't null
|
||||
if(!this.assets || !this.spine || !this.spineIndexByURL || !this.toc){
|
||||
this.stored = 0;
|
||||
|
@ -457,6 +464,11 @@ FP.Book.prototype.startDisplay = function(){
|
|||
this.tell("book:bookReady");
|
||||
this.displayChapter(this.spinePos, function(chapter){
|
||||
|
||||
//-- If there is a saved page, and the pages haven't changed go to it
|
||||
if(this.prevChapterPos && this.prevDisplayedPages == chapter.displayedPages){
|
||||
chapter.page(this.prevChapterPos);
|
||||
}
|
||||
|
||||
//-- If there is network connection, store the books contents
|
||||
if(this.online && !this.contained){
|
||||
this.storeOffline();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue