From 270f585b265f40012c76bc6e95553576cc8b285b Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Mon, 8 Jun 2020 17:44:55 +1000 Subject: [PATCH] Make book plugin render EPUBs continuously for mobile devices --- src/plugins/bookPlayer/plugin.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/plugins/bookPlayer/plugin.js b/src/plugins/bookPlayer/plugin.js index 0303275be2..8cde3f400f 100644 --- a/src/plugins/bookPlayer/plugin.js +++ b/src/plugins/bookPlayer/plugin.js @@ -1,3 +1,4 @@ +import browser from 'browser'; import loading from 'loading'; import keyboardnavigation from 'keyboardnavigation'; import dialogHelper from 'dialogHelper'; @@ -230,6 +231,23 @@ export class BookPlayer { return elem; } + render(elem, book) { + if (browser.mobile) { + return book.renderTo(elem, { + width: '100%', + height: '100%', + manager: 'continuous', + flow: 'scrolled-doc', + offset: 0 + }); + } else { + return book.renderTo(elem, { + width: '100%', + height: '100%' + }); + } + } + setCurrentSrc(elem, options) { const item = options.items[0]; this._currentItem = item; @@ -248,7 +266,7 @@ export class BookPlayer { import('epubjs').then(({default: epubjs}) => { const downloadHref = apiClient.getItemDownloadUrl(item.Id); const book = epubjs(downloadHref, {openAs: 'epub'}); - const rendition = book.renderTo(elem, {width: '100%', height: '97%'}); + const rendition = this.render(elem, book); this._currentSrc = downloadHref; this._rendition = rendition;