Skip to content

Commit

Permalink
Reopen document from last position
Browse files Browse the repository at this point in the history
  • Loading branch information
svera committed Jul 16, 2024
1 parent bef65e9 commit 806836a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/webserver/embedded/js/foliate-js/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ const getView = async file => {
}
if (!book) throw new Error('File type not supported')
const view = document.createElement('foliate-view')
const storage = window.localStorage
document.body.append(view)
await view.open(book)
view.init({lastLocation: storage.getItem("loc")})
return view
}

Expand Down Expand Up @@ -222,6 +224,8 @@ class Reader {
doc.addEventListener('keydown', this.#handleKeydown.bind(this))
}
#onRelocate({ detail }) {
const storage = window.localStorage
storage.setItem("loc", detail.cfi)
const { fraction, location, tocItem, pageItem } = detail
const percent = percentFormat.format(fraction)
const loc = pageItem
Expand Down

0 comments on commit 806836a

Please sign in to comment.