epub.js icon indicating copy to clipboard operation
epub.js copied to clipboard

How to return correct page by localstorage

Open Jacky3K opened this issue 7 years ago • 2 comments

I save the Cfi to localstorage by "renderer:locationChanged" event, like this:

Book.on('renderer:locationChanged', function(location) { obj.lastRead = location; localStorage["{{$story->id}}-{{$body->chapter}}"] = JSON.stringify(obj); });

And use "lastRead" to return the page, like:

var obj = JSON.parse(window.localStorage["{{$story->id}}-{{$body->chapter}}"]); if(obj.lastRead != 0) { Book.gotoCfi(obj.lastRead); }

But I just can return to previous page, for instance, if I stay in Page 5 and refresh the page, it will return to Page 4, how can I return the correct page when I refresh the page?

Jacky3K avatar Dec 01 '17 07:12 Jacky3K

See how I do it in: https://github.com/geek1011/ePubViewer/blob/gh-pages/script.js#L501-L508

pgaskin avatar Dec 02 '17 02:12 pgaskin

I have the same issue. After a reload, it is always one page behind.

PeeJeeDR avatar Jun 27 '22 19:06 PeeJeeDR