@internetarchive/bookreader 5.0.0-88-alpha.11 → 5.0.0-89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/BookReader/BookReader.css +17 -3
  2. package/BookReader/BookReader.js +1 -1
  3. package/BookReader/BookReader.js.map +1 -1
  4. package/BookReader/ia-bookreader-bundle.js +87 -108
  5. package/BookReader/ia-bookreader-bundle.js.map +1 -1
  6. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  7. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  8. package/BookReader/plugins/plugin.autoplay.js +1 -1
  9. package/BookReader/plugins/plugin.autoplay.js.map +1 -1
  10. package/BookReader/plugins/plugin.iiif.js +1 -1
  11. package/BookReader/plugins/plugin.iiif.js.map +1 -1
  12. package/BookReader/plugins/plugin.resume.js +1 -1
  13. package/BookReader/plugins/plugin.resume.js.map +1 -1
  14. package/BookReader/plugins/plugin.search.js +1 -1
  15. package/BookReader/plugins/plugin.search.js.map +1 -1
  16. package/BookReader/plugins/plugin.text_selection.js +1 -1
  17. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  18. package/BookReader/plugins/plugin.tts.js +1 -1
  19. package/BookReader/plugins/plugin.tts.js.map +1 -1
  20. package/BookReader/plugins/plugin.url.js +1 -1
  21. package/BookReader/plugins/plugin.url.js.map +1 -1
  22. package/CHANGELOG.md +14 -0
  23. package/babel.config.js +12 -30
  24. package/codecov.yml +1 -1
  25. package/jsconfig.json +1 -3
  26. package/package.json +14 -16
  27. package/src/BookNavigator/search/search-results.js +1 -1
  28. package/src/BookReader/ImageCache.js +48 -15
  29. package/src/BookReader/Mode1UpLit.js +56 -86
  30. package/src/BookReader/Mode2UpLit.js +5 -5
  31. package/src/BookReader/Navbar/Navbar.js +53 -11
  32. package/src/BookReader/PageContainer.js +41 -22
  33. package/src/BookReader/options.js +27 -3
  34. package/src/BookReader/utils.js +10 -0
  35. package/src/BookReader.js +120 -21
  36. package/src/BookReaderPlugin.js +44 -0
  37. package/src/css/_BRnav.scss +0 -3
  38. package/src/css/_BRpages.scss +21 -2
  39. package/src/css/_controls.scss +4 -0
  40. package/src/plugins/plugin.archive_analytics.js +84 -78
  41. package/src/plugins/plugin.autoplay.js +98 -102
  42. package/src/plugins/plugin.chapters.js +17 -22
  43. package/src/plugins/plugin.iiif.js +16 -30
  44. package/src/plugins/plugin.resume.js +54 -51
  45. package/src/plugins/plugin.text_selection.js +68 -76
  46. package/src/plugins/tts/AbstractTTSEngine.js +2 -4
  47. package/src/plugins/tts/PageChunk.js +5 -9
  48. package/src/plugins/tts/PageChunkIterator.js +3 -5
  49. package/src/plugins/tts/plugin.tts.js +309 -329
  50. package/src/plugins/url/plugin.url.js +1 -1
  51. package/src/util/strings.js +1 -0
  52. package/tests/e2e/autoplay.test.js +8 -5
  53. package/tests/e2e/helpers/base.js +2 -2
  54. package/tests/e2e/helpers/mockSearch.js +6 -9
  55. package/tests/jest/BookReader/Navbar/Navbar.test.js +16 -3
  56. package/tests/jest/BookReader/PageContainer.test.js +96 -55
  57. package/tests/jest/BookReader/utils.test.js +21 -0
  58. package/tests/jest/BookReader.test.js +13 -12
  59. package/tests/jest/plugins/plugin.archive_analytics.test.js +8 -11
  60. package/tests/jest/plugins/plugin.autoplay.test.js +9 -22
  61. package/tests/jest/plugins/plugin.resume.test.js +19 -32
  62. package/tests/jest/plugins/plugin.text_selection.test.js +23 -24
  63. package/dist/esm/BookNavigator/assets/bookmark-colors.js +0 -4
  64. package/dist/esm/BookNavigator/assets/button-base.js +0 -4
  65. package/dist/esm/BookNavigator/assets/ia-logo.js +0 -4
  66. package/dist/esm/BookNavigator/assets/icon_checkmark.js +0 -8
  67. package/dist/esm/BookNavigator/assets/icon_close.js +0 -4
  68. package/dist/esm/BookNavigator/book-navigator.js +0 -612
  69. package/dist/esm/BookNavigator/bookmarks/bookmark-button.js +0 -35
  70. package/dist/esm/BookNavigator/bookmarks/bookmark-edit.js +0 -78
  71. package/dist/esm/BookNavigator/bookmarks/bookmarks-list.js +0 -160
  72. package/dist/esm/BookNavigator/bookmarks/bookmarks-loginCTA.js +0 -24
  73. package/dist/esm/BookNavigator/bookmarks/bookmarks-provider.js +0 -55
  74. package/dist/esm/BookNavigator/bookmarks/ia-bookmarks.js +0 -521
  75. package/dist/esm/BookNavigator/delete-modal-actions.js +0 -29
  76. package/dist/esm/BookNavigator/downloads/downloads-provider.js +0 -84
  77. package/dist/esm/BookNavigator/downloads/downloads.js +0 -69
  78. package/dist/esm/BookNavigator/search/search-provider.js +0 -238
  79. package/dist/esm/BookNavigator/search/search-results.js +0 -161
  80. package/dist/esm/BookNavigator/sharing.js +0 -26
  81. package/dist/esm/BookNavigator/viewable-files.js +0 -94
  82. package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments-provider.js +0 -83
  83. package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments.js +0 -131
  84. package/dist/esm/BookReader/BookModel.js +0 -575
  85. package/dist/esm/BookReader/DragScrollable.js +0 -224
  86. package/dist/esm/BookReader/ImageCache.js +0 -122
  87. package/dist/esm/BookReader/Mode1Up.js +0 -114
  88. package/dist/esm/BookReader/Mode1UpLit.js +0 -579
  89. package/dist/esm/BookReader/Mode2Up.js +0 -106
  90. package/dist/esm/BookReader/Mode2UpLit.js +0 -1020
  91. package/dist/esm/BookReader/ModeCoordinateSpace.js +0 -28
  92. package/dist/esm/BookReader/ModeSmoothZoom.js +0 -318
  93. package/dist/esm/BookReader/ModeThumb.js +0 -366
  94. package/dist/esm/BookReader/Navbar/Navbar.js +0 -253
  95. package/dist/esm/BookReader/PageContainer.js +0 -165
  96. package/dist/esm/BookReader/ReduceSet.js +0 -27
  97. package/dist/esm/BookReader/Toolbar/Toolbar.js +0 -242
  98. package/dist/esm/BookReader/events.js +0 -20
  99. package/dist/esm/BookReader/options.js +0 -331
  100. package/dist/esm/BookReader/utils/HTMLDimensionsCacher.js +0 -48
  101. package/dist/esm/BookReader/utils/ScrollClassAdder.js +0 -31
  102. package/dist/esm/BookReader/utils/SelectionObserver.js +0 -42
  103. package/dist/esm/BookReader/utils/classes.js +0 -37
  104. package/dist/esm/BookReader/utils.js +0 -315
  105. package/dist/esm/BookReader.js +0 -1828
  106. package/dist/esm/assets/icons/1up.svg +0 -12
  107. package/dist/esm/assets/icons/2up.svg +0 -15
  108. package/dist/esm/assets/icons/advance.svg +0 -26
  109. package/dist/esm/assets/icons/chevron-right.svg +0 -1
  110. package/dist/esm/assets/icons/close-circle-dark.svg +0 -1
  111. package/dist/esm/assets/icons/close-circle.svg +0 -1
  112. package/dist/esm/assets/icons/fullscreen.svg +0 -17
  113. package/dist/esm/assets/icons/fullscreen_exit.svg +0 -17
  114. package/dist/esm/assets/icons/hamburger.svg +0 -15
  115. package/dist/esm/assets/icons/left-arrow.svg +0 -12
  116. package/dist/esm/assets/icons/magnify-minus.svg +0 -12
  117. package/dist/esm/assets/icons/magnify-plus.svg +0 -13
  118. package/dist/esm/assets/icons/magnify.svg +0 -15
  119. package/dist/esm/assets/icons/pause.svg +0 -23
  120. package/dist/esm/assets/icons/play.svg +0 -22
  121. package/dist/esm/assets/icons/playback-speed.svg +0 -34
  122. package/dist/esm/assets/icons/read-aloud.svg +0 -22
  123. package/dist/esm/assets/icons/review.svg +0 -22
  124. package/dist/esm/assets/icons/thumbnails.svg +0 -17
  125. package/dist/esm/assets/icons/voice.svg +0 -1
  126. package/dist/esm/assets/icons/volume-full.svg +0 -22
  127. package/dist/esm/assets/images/BRicons.png +0 -0
  128. package/dist/esm/assets/images/BRicons.svg +0 -94
  129. package/dist/esm/assets/images/BRicons_ia.png +0 -0
  130. package/dist/esm/assets/images/back_pages.png +0 -0
  131. package/dist/esm/assets/images/book_bottom_icon.png +0 -0
  132. package/dist/esm/assets/images/book_down_icon.png +0 -0
  133. package/dist/esm/assets/images/book_left_icon.png +0 -0
  134. package/dist/esm/assets/images/book_leftmost_icon.png +0 -0
  135. package/dist/esm/assets/images/book_right_icon.png +0 -0
  136. package/dist/esm/assets/images/book_rightmost_icon.png +0 -0
  137. package/dist/esm/assets/images/book_top_icon.png +0 -0
  138. package/dist/esm/assets/images/book_up_icon.png +0 -0
  139. package/dist/esm/assets/images/books_graphic.svg +0 -177
  140. package/dist/esm/assets/images/booksplit.png +0 -0
  141. package/dist/esm/assets/images/control_pause_icon.png +0 -0
  142. package/dist/esm/assets/images/control_play_icon.png +0 -0
  143. package/dist/esm/assets/images/embed_icon.png +0 -0
  144. package/dist/esm/assets/images/icon-home-ia.png +0 -0
  145. package/dist/esm/assets/images/icon_OL-logo-xs.png +0 -0
  146. package/dist/esm/assets/images/icon_alert-xs.png +0 -0
  147. package/dist/esm/assets/images/icon_book.svg +0 -12
  148. package/dist/esm/assets/images/icon_bookmark.svg +0 -12
  149. package/dist/esm/assets/images/icon_close-pop.png +0 -0
  150. package/dist/esm/assets/images/icon_download.png +0 -0
  151. package/dist/esm/assets/images/icon_gear.svg +0 -14
  152. package/dist/esm/assets/images/icon_hamburger.svg +0 -20
  153. package/dist/esm/assets/images/icon_home.png +0 -0
  154. package/dist/esm/assets/images/icon_home.svg +0 -21
  155. package/dist/esm/assets/images/icon_home_ia.png +0 -0
  156. package/dist/esm/assets/images/icon_indicator.png +0 -0
  157. package/dist/esm/assets/images/icon_info.svg +0 -11
  158. package/dist/esm/assets/images/icon_one_page.svg +0 -8
  159. package/dist/esm/assets/images/icon_pause.svg +0 -1
  160. package/dist/esm/assets/images/icon_play.svg +0 -1
  161. package/dist/esm/assets/images/icon_playback-rate.svg +0 -15
  162. package/dist/esm/assets/images/icon_return.png +0 -0
  163. package/dist/esm/assets/images/icon_search_button.svg +0 -8
  164. package/dist/esm/assets/images/icon_share.svg +0 -9
  165. package/dist/esm/assets/images/icon_skip-ahead.svg +0 -6
  166. package/dist/esm/assets/images/icon_skip-back.svg +0 -13
  167. package/dist/esm/assets/images/icon_speaker.svg +0 -18
  168. package/dist/esm/assets/images/icon_speaker_open.svg +0 -10
  169. package/dist/esm/assets/images/icon_thumbnails.svg +0 -12
  170. package/dist/esm/assets/images/icon_toc.svg +0 -5
  171. package/dist/esm/assets/images/icon_two_pages.svg +0 -9
  172. package/dist/esm/assets/images/icon_zoomer.png +0 -0
  173. package/dist/esm/assets/images/loading.gif +0 -0
  174. package/dist/esm/assets/images/logo_icon.png +0 -0
  175. package/dist/esm/assets/images/marker_chap-off.png +0 -0
  176. package/dist/esm/assets/images/marker_chap-off.svg +0 -11
  177. package/dist/esm/assets/images/marker_chap-off_ia.png +0 -0
  178. package/dist/esm/assets/images/marker_chap-on.png +0 -0
  179. package/dist/esm/assets/images/marker_chap-on.svg +0 -11
  180. package/dist/esm/assets/images/marker_srch-on.svg +0 -11
  181. package/dist/esm/assets/images/marker_srchchap-off.png +0 -0
  182. package/dist/esm/assets/images/marker_srchchap-on.png +0 -0
  183. package/dist/esm/assets/images/nav_control-dn.png +0 -0
  184. package/dist/esm/assets/images/nav_control-dn_ia.png +0 -0
  185. package/dist/esm/assets/images/nav_control-up.png +0 -0
  186. package/dist/esm/assets/images/nav_control-up_ia.png +0 -0
  187. package/dist/esm/assets/images/nav_control.png +0 -0
  188. package/dist/esm/assets/images/one_page_mode_icon.png +0 -0
  189. package/dist/esm/assets/images/paper-badge.png +0 -0
  190. package/dist/esm/assets/images/print_icon.png +0 -0
  191. package/dist/esm/assets/images/progressbar.gif +0 -0
  192. package/dist/esm/assets/images/right_edges.png +0 -0
  193. package/dist/esm/assets/images/slider.png +0 -0
  194. package/dist/esm/assets/images/slider_ia.png +0 -0
  195. package/dist/esm/assets/images/thumbnail_mode_icon.png +0 -0
  196. package/dist/esm/assets/images/transparent.png +0 -0
  197. package/dist/esm/assets/images/two_page_mode_icon.png +0 -0
  198. package/dist/esm/assets/images/unviewable_page.png +0 -0
  199. package/dist/esm/assets/images/zoom_in_icon.png +0 -0
  200. package/dist/esm/assets/images/zoom_out_icon.png +0 -0
  201. package/dist/esm/css/BookReader.scss +0 -85
  202. package/dist/esm/css/_BRBookmarks.scss +0 -29
  203. package/dist/esm/css/_BRComponent.scss +0 -13
  204. package/dist/esm/css/_BRfloat.scss +0 -197
  205. package/dist/esm/css/_BRicon.scss +0 -54
  206. package/dist/esm/css/_BRmain.scss +0 -262
  207. package/dist/esm/css/_BRnav.scss +0 -354
  208. package/dist/esm/css/_BRpages.scss +0 -213
  209. package/dist/esm/css/_BRsearch.scss +0 -268
  210. package/dist/esm/css/_BRtoolbar.scss +0 -84
  211. package/dist/esm/css/_BRvendor.scss +0 -5
  212. package/dist/esm/css/_TextSelection.scss +0 -108
  213. package/dist/esm/css/_colorbox.scss +0 -52
  214. package/dist/esm/css/_controls.scss +0 -257
  215. package/dist/esm/css/_icons.scss +0 -121
  216. package/dist/esm/ia-bookreader/ia-bookreader.js +0 -141
  217. package/dist/esm/jquery-wrapper.js +0 -3
  218. package/dist/esm/plugins/plugin.archive_analytics.js +0 -72
  219. package/dist/esm/plugins/plugin.autoplay.js +0 -119
  220. package/dist/esm/plugins/plugin.chapters.js +0 -288
  221. package/dist/esm/plugins/plugin.iframe.js +0 -44
  222. package/dist/esm/plugins/plugin.iiif.js +0 -146
  223. package/dist/esm/plugins/plugin.resume.js +0 -66
  224. package/dist/esm/plugins/plugin.text_selection.js +0 -621
  225. package/dist/esm/plugins/plugin.vendor-fullscreen.js +0 -227
  226. package/dist/esm/plugins/search/plugin.search.js +0 -499
  227. package/dist/esm/plugins/search/utils.js +0 -42
  228. package/dist/esm/plugins/search/view.js +0 -360
  229. package/dist/esm/plugins/tts/AbstractTTSEngine.js +0 -282
  230. package/dist/esm/plugins/tts/FestivalTTSEngine.js +0 -192
  231. package/dist/esm/plugins/tts/PageChunk.js +0 -105
  232. package/dist/esm/plugins/tts/PageChunkIterator.js +0 -155
  233. package/dist/esm/plugins/tts/WebTTSEngine.js +0 -364
  234. package/dist/esm/plugins/tts/plugin.tts.js +0 -315
  235. package/dist/esm/plugins/tts/tooltip_dict.js +0 -14
  236. package/dist/esm/plugins/tts/utils.js +0 -79
  237. package/dist/esm/plugins/url/UrlPlugin.js +0 -197
  238. package/dist/esm/plugins/url/plugin.url.js +0 -212
  239. package/dist/esm/util/browserSniffing.js +0 -56
  240. package/dist/esm/util/debouncer.js +0 -25
  241. package/dist/esm/util/docCookies.js +0 -75
  242. package/dist/esm/util/strings.js +0 -34
  243. package/index.js +0 -2
@@ -1,579 +0,0 @@
1
- var _templateObject;
2
- function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
3
- function _decorate(e, r, t, i) { var o = _getDecoratorsApi(); if (i) for (var n = 0; n < i.length; n++) o = i[n](o); var s = r(function (e) { o.initializeInstanceElements(e, a.elements); }, t), a = o.decorateClass(_coalesceClassElements(s.d.map(_createElementDescriptor)), e); return o.initializeClassElements(s.F, a.elements), o.runClassFinishers(s.F, a.finishers); }
4
- function _getDecoratorsApi() { _getDecoratorsApi = function _getDecoratorsApi() { return e; }; var e = { elementsDefinitionOrder: [["method"], ["field"]], initializeInstanceElements: function initializeInstanceElements(e, r) { ["method", "field"].forEach(function (t) { r.forEach(function (r) { r.kind === t && "own" === r.placement && this.defineClassElement(e, r); }, this); }, this); }, initializeClassElements: function initializeClassElements(e, r) { var t = e.prototype; ["method", "field"].forEach(function (i) { r.forEach(function (r) { var o = r.placement; if (r.kind === i && ("static" === o || "prototype" === o)) { var n = "static" === o ? e : t; this.defineClassElement(n, r); } }, this); }, this); }, defineClassElement: function defineClassElement(e, r) { var t = r.descriptor; if ("field" === r.kind) { var i = r.initializer; t = { enumerable: t.enumerable, writable: t.writable, configurable: t.configurable, value: void 0 === i ? void 0 : i.call(e) }; } Object.defineProperty(e, r.key, t); }, decorateClass: function decorateClass(e, r) { var t = [], i = [], o = { static: [], prototype: [], own: [] }; if (e.forEach(function (e) { this.addElementPlacement(e, o); }, this), e.forEach(function (e) { if (!_hasDecorators(e)) return t.push(e); var r = this.decorateElement(e, o); t.push(r.element), t.push.apply(t, r.extras), i.push.apply(i, r.finishers); }, this), !r) return { elements: t, finishers: i }; var n = this.decorateConstructor(t, r); return i.push.apply(i, n.finishers), n.finishers = i, n; }, addElementPlacement: function addElementPlacement(e, r, t) { var i = r[e.placement]; if (!t && -1 !== i.indexOf(e.key)) throw new TypeError("Duplicated element (" + e.key + ")"); i.push(e.key); }, decorateElement: function decorateElement(e, r) { for (var t = [], i = [], o = e.decorators, n = o.length - 1; n >= 0; n--) { var s = r[e.placement]; s.splice(s.indexOf(e.key), 1); var a = this.fromElementDescriptor(e), l = this.toElementFinisherExtras((0, o[n])(a) || a); e = l.element, this.addElementPlacement(e, r), l.finisher && i.push(l.finisher); var c = l.extras; if (c) { for (var p = 0; p < c.length; p++) this.addElementPlacement(c[p], r); t.push.apply(t, c); } } return { element: e, finishers: i, extras: t }; }, decorateConstructor: function decorateConstructor(e, r) { for (var t = [], i = r.length - 1; i >= 0; i--) { var o = this.fromClassDescriptor(e), n = this.toClassDescriptor((0, r[i])(o) || o); if (void 0 !== n.finisher && t.push(n.finisher), void 0 !== n.elements) { e = n.elements; for (var s = 0; s < e.length - 1; s++) for (var a = s + 1; a < e.length; a++) if (e[s].key === e[a].key && e[s].placement === e[a].placement) throw new TypeError("Duplicated element (" + e[s].key + ")"); } } return { elements: e, finishers: t }; }, fromElementDescriptor: function fromElementDescriptor(e) { var r = { kind: e.kind, key: e.key, placement: e.placement, descriptor: e.descriptor }; return Object.defineProperty(r, Symbol.toStringTag, { value: "Descriptor", configurable: !0 }), "field" === e.kind && (r.initializer = e.initializer), r; }, toElementDescriptors: function toElementDescriptors(e) { if (void 0 !== e) return _toArray(e).map(function (e) { var r = this.toElementDescriptor(e); return this.disallowProperty(e, "finisher", "An element descriptor"), this.disallowProperty(e, "extras", "An element descriptor"), r; }, this); }, toElementDescriptor: function toElementDescriptor(e) { var r = e.kind + ""; if ("method" !== r && "field" !== r) throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "' + r + '"'); var t = _toPropertyKey(e.key), i = e.placement + ""; if ("static" !== i && "prototype" !== i && "own" !== i) throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "' + i + '"'); var o = e.descriptor; this.disallowProperty(e, "elements", "An element descriptor"); var n = { kind: r, key: t, placement: i, descriptor: Object.assign({}, o) }; return "field" !== r ? this.disallowProperty(e, "initializer", "A method descriptor") : (this.disallowProperty(o, "get", "The property descriptor of a field descriptor"), this.disallowProperty(o, "set", "The property descriptor of a field descriptor"), this.disallowProperty(o, "value", "The property descriptor of a field descriptor"), n.initializer = e.initializer), n; }, toElementFinisherExtras: function toElementFinisherExtras(e) { return { element: this.toElementDescriptor(e), finisher: _optionalCallableProperty(e, "finisher"), extras: this.toElementDescriptors(e.extras) }; }, fromClassDescriptor: function fromClassDescriptor(e) { var r = { kind: "class", elements: e.map(this.fromElementDescriptor, this) }; return Object.defineProperty(r, Symbol.toStringTag, { value: "Descriptor", configurable: !0 }), r; }, toClassDescriptor: function toClassDescriptor(e) { var r = e.kind + ""; if ("class" !== r) throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "' + r + '"'); this.disallowProperty(e, "key", "A class descriptor"), this.disallowProperty(e, "placement", "A class descriptor"), this.disallowProperty(e, "descriptor", "A class descriptor"), this.disallowProperty(e, "initializer", "A class descriptor"), this.disallowProperty(e, "extras", "A class descriptor"); var t = _optionalCallableProperty(e, "finisher"); return { elements: this.toElementDescriptors(e.elements), finisher: t }; }, runClassFinishers: function runClassFinishers(e, r) { for (var t = 0; t < r.length; t++) { var i = (0, r[t])(e); if (void 0 !== i) { if ("function" != typeof i) throw new TypeError("Finishers must return a constructor."); e = i; } } return e; }, disallowProperty: function disallowProperty(e, r, t) { if (void 0 !== e[r]) throw new TypeError(t + " can't have a ." + r + " property."); } }; return e; }
5
- function _createElementDescriptor(e) { var r, t = _toPropertyKey(e.key); "method" === e.kind ? r = { value: e.value, writable: !0, configurable: !0, enumerable: !1 } : "get" === e.kind ? r = { get: e.value, configurable: !0, enumerable: !1 } : "set" === e.kind ? r = { set: e.value, configurable: !0, enumerable: !1 } : "field" === e.kind && (r = { configurable: !0, writable: !0, enumerable: !0 }); var i = { kind: "field" === e.kind ? "field" : "method", key: t, placement: e.static ? "static" : "field" === e.kind ? "own" : "prototype", descriptor: r }; return e.decorators && (i.decorators = e.decorators), "field" === e.kind && (i.initializer = e.value), i; }
6
- function _coalesceGetterSetter(e, r) { void 0 !== e.descriptor.get ? r.descriptor.get = e.descriptor.get : r.descriptor.set = e.descriptor.set; }
7
- function _coalesceClassElements(e) { for (var r = [], isSameElement = function isSameElement(e) { return "method" === e.kind && e.key === o.key && e.placement === o.placement; }, t = 0; t < e.length; t++) { var i, o = e[t]; if ("method" === o.kind && (i = r.find(isSameElement))) { if (_isDataDescriptor(o.descriptor) || _isDataDescriptor(i.descriptor)) { if (_hasDecorators(o) || _hasDecorators(i)) throw new ReferenceError("Duplicated methods (" + o.key + ") can't be decorated."); i.descriptor = o.descriptor; } else { if (_hasDecorators(o)) { if (_hasDecorators(i)) throw new ReferenceError("Decorators can't be placed on different accessors with for the same property (" + o.key + ")."); i.decorators = o.decorators; } _coalesceGetterSetter(o, i); } } else r.push(o); } return r; }
8
- function _hasDecorators(e) { return e.decorators && e.decorators.length; }
9
- function _isDataDescriptor(e) { return void 0 !== e && !(void 0 === e.value && void 0 === e.writable); }
10
- function _optionalCallableProperty(e, r) { var t = e[r]; if (void 0 !== t && "function" != typeof t) throw new TypeError("Expected '" + r + "' to be a function"); return t; }
11
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
12
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
14
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
16
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
17
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
18
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
19
- function _superPropGet(t, e, o, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), e, o); return 2 & r && "function" == typeof p ? function (t) { return p.apply(o, t); } : p; }
20
- function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
21
- function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
22
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
23
- // @ts-check
24
- import { property, query } from 'lit/decorators.js';
25
- import { LitElement, html } from 'lit';
26
- import { styleMap } from 'lit/directives/style-map.js';
27
- import { ModeSmoothZoom } from './ModeSmoothZoom';
28
- import { arrChanged, genToArray, sum, throttle } from './utils';
29
- import { HTMLDimensionsCacher } from './utils/HTMLDimensionsCacher';
30
- import { ScrollClassAdder } from './utils/ScrollClassAdder';
31
- import { ModeCoordinateSpace } from './ModeCoordinateSpace';
32
- /** @typedef {import('./BookModel').BookModel} BookModel */
33
- /** @typedef {import('./BookModel').PageIndex} PageIndex */
34
- /** @typedef {import('./BookModel').PageModel} PageModel */
35
- /** @typedef {import('./ModeSmoothZoom').SmoothZoomable} SmoothZoomable */
36
- /** @typedef {import('./PageContainer').PageContainer} PageContainer */
37
- /** @typedef {import('../BookReader').default} BookReader */
38
-
39
- // I _have_ to make this globally public, otherwise it won't let me call
40
- // it's constructor :/
41
- /** @implements {SmoothZoomable} */
42
- export var Mode1UpLit = _decorate(null, function (_initialize, _LitElement) {
43
- class Mode1UpLit extends _LitElement {
44
- /****************************************/
45
- /************** PROPERTIES **************/
46
- /****************************************/
47
-
48
- /** @type {BookReader} */
49
-
50
- /************** BOOK-RELATED PROPERTIES **************/
51
-
52
- /** @type {BookModel} */
53
-
54
- /** @type {PageModel[]} */
55
-
56
- /** @type {Record<PageIndex, number>} in world coordinates (inches) */
57
-
58
- /************** SCALE-RELATED PROPERTIES **************/
59
-
60
- /** @type {ModeCoordinateSpace} Manage conversion between coordinates */
61
-
62
- /************** VIRTUAL-SCROLLING PROPERTIES **************/
63
-
64
- /** in world coordinates (inches) */
65
-
66
- /** @type {PageModel[]} */
67
-
68
- /** @type {PageModel[]} */
69
-
70
- /** @type {Record<PageIndex, PageContainer>} position in inches */
71
-
72
- /************** WORLD-RELATED PROPERTIES **************/
73
- /**
74
- * The world is an imaginary giant document that contains all the pages.
75
- * The "world"'s size is used to determine how long the scroll bar should
76
- * be, for example.
77
- */
78
-
79
- /** @type {HTMLElement} */
80
-
81
- /** @type {HTMLElement} */
82
-
83
- /** @type {HTMLElement} */
84
-
85
- /************** DOM-RELATED PROPERTIES **************/
86
-
87
- /** @type {HTMLDimensionsCacher} Cache things like clientWidth to reduce repaints */
88
-
89
- /************** CONSTANT PROPERTIES **************/
90
-
91
- /** Vertical space between/around the pages in inches */
92
-
93
- /** How much to zoom when zoom button pressed */
94
-
95
- /****************************************/
96
- /************** PUBLIC API **************/
97
- /****************************************/
98
-
99
- /************** MAIN PUBLIC METHODS **************/
100
-
101
- /**
102
- * @param {PageIndex} index
103
- */
104
-
105
- /********************************************/
106
- /************** INTERNAL STUFF **************/
107
- /********************************************/
108
-
109
- /************** LIFE CYCLE **************/
110
-
111
- /**
112
- * @param {BookModel} book
113
- * @param {BookReader} br
114
- */
115
- constructor(book, br) {
116
- super();
117
- _initialize(this);
118
- this.book = book;
119
-
120
- /** @type {BookReader} */
121
- this.br = br;
122
- }
123
-
124
- /** @override */
125
-
126
- /**
127
- * @param {PageIndex} startIndex
128
- */
129
-
130
- /** @override */
131
-
132
- /** @override */
133
-
134
- /** @override */
135
-
136
- /************** LIT CONFIGS **************/
137
-
138
- /** @override */
139
-
140
- /************** RENDERING **************/
141
-
142
- /** @override */
143
-
144
- /** @param {PageModel} page */
145
-
146
- /** @param {PageModel} page */
147
-
148
- /************** VIRTUAL SCROLLING LOGIC **************/
149
-
150
- /**
151
- * @returns {PageModel[]}
152
- */
153
-
154
- /**
155
- * @param {PageModel[]} pages
156
- * @param {number} spacing
157
- */
158
-
159
- /**
160
- * @param {PageModel} page
161
- * @returns {number}
162
- */
163
-
164
- /************** INPUT HANDLERS **************/
165
- }
166
- return {
167
- F: Mode1UpLit,
168
- d: [{
169
- kind: "field",
170
- key: "br",
171
- value: void 0
172
- }, {
173
- kind: "field",
174
- decorators: [property({
175
- type: Object
176
- })],
177
- key: "book",
178
- value: void 0
179
- }, {
180
- kind: "field",
181
- decorators: [property({
182
- type: Array
183
- })],
184
- key: "pages",
185
- value() {
186
- return [];
187
- }
188
- }, {
189
- kind: "field",
190
- decorators: [property({
191
- type: Object
192
- })],
193
- key: "pageTops",
194
- value() {
195
- return {};
196
- }
197
- }, {
198
- kind: "field",
199
- key: "coordSpace",
200
- value() {
201
- return new ModeCoordinateSpace(this);
202
- }
203
- }, {
204
- kind: "field",
205
- decorators: [property({
206
- type: Number
207
- })],
208
- key: "scale",
209
- value() {
210
- return 1;
211
- }
212
- }, {
213
- kind: "field",
214
- decorators: [property({
215
- type: Object
216
- })],
217
- key: "visibleRegion",
218
- value() {
219
- return {
220
- top: 0,
221
- left: 0,
222
- width: 100,
223
- height: 100
224
- };
225
- }
226
- }, {
227
- kind: "field",
228
- decorators: [property({
229
- type: Array,
230
- hasChanged: arrChanged
231
- })],
232
- key: "visiblePages",
233
- value() {
234
- return [];
235
- }
236
- }, {
237
- kind: "field",
238
- decorators: [property({
239
- type: Array
240
- })],
241
- key: "renderedPages",
242
- value() {
243
- return [];
244
- }
245
- }, {
246
- kind: "field",
247
- key: "pageContainerCache",
248
- value() {
249
- return {};
250
- }
251
- }, {
252
- kind: "field",
253
- decorators: [query('.br-mode-1up__world')],
254
- key: "$world",
255
- value: void 0
256
- }, {
257
- kind: "field",
258
- key: "worldDimensions",
259
- value() {
260
- return {
261
- width: 100,
262
- height: 100
263
- };
264
- }
265
- }, {
266
- kind: "get",
267
- key: "worldStyle",
268
- value: function value() {
269
- var wToR = this.coordSpace.worldUnitsToRenderedPixels;
270
- return {
271
- width: wToR(this.worldDimensions.width) + 'px',
272
- height: wToR(this.worldDimensions.height) + 'px'
273
- };
274
- }
275
- }, {
276
- kind: "get",
277
- key: "$container",
278
- value: function value() {
279
- return this;
280
- }
281
- }, {
282
- kind: "field",
283
- decorators: [query('.br-mode-1up__visible-world')],
284
- key: "$visibleWorld",
285
- value: void 0
286
- }, {
287
- kind: "field",
288
- key: "htmlDimensionsCacher",
289
- value() {
290
- return new HTMLDimensionsCacher(this);
291
- }
292
- }, {
293
- kind: "field",
294
- key: "smoothZoomer",
295
- value() {
296
- return new ModeSmoothZoom(this);
297
- }
298
- }, {
299
- kind: "field",
300
- key: "scrollClassAdder",
301
- value() {
302
- return new ScrollClassAdder(this, 'BRscrolling-active');
303
- }
304
- }, {
305
- kind: "field",
306
- key: "SPACING_IN",
307
- value() {
308
- return 0.2;
309
- }
310
- }, {
311
- kind: "field",
312
- key: "ZOOM_FACTOR",
313
- value() {
314
- return 1.1;
315
- }
316
- }, {
317
- kind: "method",
318
- key: "jumpToIndex",
319
- value: function jumpToIndex(index) {
320
- var {
321
- smooth = false
322
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
323
- if (smooth) {
324
- this.style.scrollBehavior = 'smooth';
325
- }
326
- this.scrollTop = this.coordSpace.worldUnitsToVisiblePixels(this.pageTops[index] - this.SPACING_IN / 2);
327
- // TODO: Also h center?
328
- if (smooth) {
329
- setTimeout(() => this.style.scrollBehavior = '', 100);
330
- }
331
- }
332
- }, {
333
- kind: "method",
334
- key: "zoomIn",
335
- value: function zoomIn() {
336
- this.scale *= this.ZOOM_FACTOR;
337
- }
338
- }, {
339
- kind: "method",
340
- key: "zoomOut",
341
- value: function zoomOut() {
342
- this.scale *= 1 / this.ZOOM_FACTOR;
343
- }
344
- }, {
345
- kind: "method",
346
- key: "firstUpdated",
347
- value: function firstUpdated(changedProps) {
348
- _superPropGet(Mode1UpLit, "firstUpdated", this, 3)([changedProps]);
349
- this.htmlDimensionsCacher.updateClientSizes();
350
- this.smoothZoomer.attach();
351
- }
352
- }, {
353
- kind: "method",
354
- key: "initFirstRender",
355
- value: function initFirstRender(startIndex) {
356
- var page = this.book.getPage(startIndex);
357
- this.scale = this.computeDefaultScale(page);
358
- }
359
- }, {
360
- kind: "method",
361
- key: "updated",
362
- value: function updated(changedProps) {
363
- // this.X is the new value
364
- // changedProps.get('X') is the old value
365
- if (changedProps.has('book')) {
366
- this.updatePages();
367
- }
368
- if (changedProps.has('pages')) {
369
- this.worldDimensions = this.computeWorldDimensions();
370
- this.pageTops = this.computePageTops(this.pages, this.SPACING_IN);
371
- }
372
- if (changedProps.has('visibleRegion')) {
373
- this.visiblePages = this.computeVisiblePages();
374
- }
375
- if (changedProps.has('visiblePages')) {
376
- this.throttledUpdateRenderedPages();
377
- if (this.visiblePages.length) {
378
- // unclear why this is ever really happening
379
- this.br.displayedIndices = this.visiblePages.map(p => p.index);
380
- this.br.updateFirstIndex(this.br.displayedIndices[0]);
381
- this.br._components.navbar.updateNavIndexThrottled();
382
- }
383
- }
384
- if (changedProps.has('scale')) {
385
- var oldVal = changedProps.get('scale');
386
- // Need to set this scale to actually scale the pages
387
- this.$visibleWorld.style.transform = "scale(".concat(this.scale, ")");
388
- this.smoothZoomer.updateViewportOnZoom(this.scale, oldVal);
389
- this.updateVisibleRegion();
390
- // Need to set this scale to update the world size, so the scrollbar gets the correct size
391
- this.$world.style.transform = "scale(".concat(this.scale, ")");
392
- }
393
- }
394
- }, {
395
- kind: "method",
396
- key: "updatePages",
397
- value: function updatePages() {
398
- this.pages = genToArray(this.book.pagesIterator({
399
- combineConsecutiveUnviewables: true
400
- }));
401
- }
402
- }, {
403
- kind: "method",
404
- key: "connectedCallback",
405
- value: function connectedCallback() {
406
- _superPropGet(Mode1UpLit, "connectedCallback", this, 3)([]);
407
- this.htmlDimensionsCacher.attachResizeListener();
408
- this.attachScrollListeners();
409
- this.smoothZoomer.attach();
410
- }
411
- }, {
412
- kind: "method",
413
- key: "disconnectedCallback",
414
- value: function disconnectedCallback() {
415
- this.htmlDimensionsCacher.detachResizeListener();
416
- this.detachScrollListeners();
417
- this.smoothZoomer.detach();
418
- _superPropGet(Mode1UpLit, "disconnectedCallback", this, 3)([]);
419
- }
420
- }, {
421
- kind: "method",
422
- key: "createRenderRoot",
423
- value: function createRenderRoot() {
424
- // Disable shadow DOM; that would require a huge rejiggering of CSS
425
- return this;
426
- }
427
- }, {
428
- kind: "method",
429
- key: "render",
430
- value: function render() {
431
- return html(_templateObject || (_templateObject = _taggedTemplateLiteral([" <div\n class=\"br-mode-1up__world\"\n style=", "\n ></div>\n <div class=\"br-mode-1up__visible-world\">\n ", "\n </div>"])), styleMap(this.worldStyle), this.renderedPages.map(p => this.renderPage(p)));
432
- }
433
- }, {
434
- kind: "field",
435
- key: "createPageContainer",
436
- value() {
437
- return page => {
438
- return this.pageContainerCache[page.index] || (this.pageContainerCache[page.index] =
439
- // @ts-ignore I know it's protected, TS! But Mode1Up and BookReader are friends.
440
- this.br._createPageContainer(page.index));
441
- };
442
- }
443
- }, {
444
- kind: "field",
445
- key: "renderPage",
446
- value() {
447
- return page => {
448
- var wToR = this.coordSpace.worldUnitsToRenderedPixels;
449
- var wToV = this.coordSpace.worldUnitsToVisiblePixels;
450
- var containerWidth = this.coordSpace.visiblePixelsToWorldUnits(this.htmlDimensionsCacher.clientWidth);
451
- var width = wToR(page.widthInches);
452
- var height = wToR(page.heightInches);
453
- var left = Math.max(this.SPACING_IN, (containerWidth - page.widthInches) / 2);
454
- var top = this.pageTops[page.index];
455
- var transform = "translate(".concat(wToR(left), "px, ").concat(wToR(top), "px)");
456
- var pageContainerEl = this.createPageContainer(page).update({
457
- dimensions: {
458
- width,
459
- height,
460
- top: 0,
461
- left: 0
462
- },
463
- reduce: page.width / wToV(page.widthInches)
464
- }).$container[0];
465
- pageContainerEl.style.transform = transform;
466
- pageContainerEl.classList.toggle('BRpage-visible', this.visiblePages.includes(page));
467
- return pageContainerEl;
468
- };
469
- }
470
- }, {
471
- kind: "field",
472
- key: "updateVisibleRegion",
473
- value() {
474
- return () => {
475
- var {
476
- scrollTop,
477
- scrollLeft
478
- } = this;
479
- // clientHeight excludes scrollbars, which is good.
480
- var clientWidth = this.htmlDimensionsCacher.clientWidth;
481
- var clientHeight = this.htmlDimensionsCacher.clientHeight;
482
-
483
- // Note: scrollTop, and clientWidth all are in visible space;
484
- // i.e. they are affects by the CSS transforms.
485
-
486
- var vToW = this.coordSpace.visiblePixelsToWorldUnits;
487
- this.visibleRegion = {
488
- top: vToW(scrollTop),
489
- height: vToW(clientHeight),
490
- // TODO: These are very likely wrong
491
- left: vToW(scrollLeft),
492
- width: vToW(clientWidth)
493
- };
494
- };
495
- }
496
- }, {
497
- kind: "method",
498
- key: "computeRenderedPages",
499
- value: function computeRenderedPages() {
500
- var _this$visiblePages$, _this$visiblePages;
501
- // Also render 1 page before/after
502
- // @ts-ignore TS doesn't understand the filtering out of null values
503
- return [(_this$visiblePages$ = this.visiblePages[0]) === null || _this$visiblePages$ === void 0 ? void 0 : _this$visiblePages$.prev, ...this.visiblePages, (_this$visiblePages = this.visiblePages[this.visiblePages.length - 1]) === null || _this$visiblePages === void 0 ? void 0 : _this$visiblePages.next].filter(p => p)
504
- // Never render more than 10 pages! Usually means something is wrong
505
- .slice(0, 10);
506
- }
507
- }, {
508
- kind: "field",
509
- key: "throttledUpdateRenderedPages",
510
- value() {
511
- return throttle(() => {
512
- this.renderedPages = this.computeRenderedPages();
513
- this.requestUpdate();
514
- }, 100, null);
515
- }
516
- }, {
517
- kind: "method",
518
- key: "computePageTops",
519
- value: function computePageTops(pages, spacing) {
520
- /** @type {{ [pageIndex: string]: number }} */
521
- var result = {};
522
- var top = spacing;
523
- for (var page of pages) {
524
- result[page.index] = top;
525
- top += page.heightInches + spacing;
526
- }
527
- return result;
528
- }
529
- }, {
530
- kind: "method",
531
- key: "computeDefaultScale",
532
- value: function computeDefaultScale(page) {
533
- // Default to real size if it fits, otherwise default to full width
534
- var containerWidthIn = this.coordSpace.renderedPixelsToWorldUnits(this.clientWidth);
535
- return Math.min(1, containerWidthIn / (page.widthInches + 2 * this.SPACING_IN)) || 1;
536
- }
537
- }, {
538
- kind: "method",
539
- key: "computeWorldDimensions",
540
- value: function computeWorldDimensions() {
541
- return {
542
- width: Math.max(...this.pages.map(p => p.widthInches)) + 2 * this.SPACING_IN,
543
- height: sum(this.pages.map(p => p.heightInches)) + (this.pages.length + 1) * this.SPACING_IN
544
- };
545
- }
546
- }, {
547
- kind: "method",
548
- key: "computeVisiblePages",
549
- value: function computeVisiblePages() {
550
- return this.pages.filter(page => {
551
- var PT = this.pageTops[page.index];
552
- var PB = PT + page.heightInches;
553
- var VT = this.visibleRegion.top;
554
- var VB = VT + this.visibleRegion.height;
555
- return PT <= VB && PB >= VT;
556
- });
557
- }
558
- }, {
559
- kind: "field",
560
- key: "attachScrollListeners",
561
- value() {
562
- return () => {
563
- this.addEventListener('scroll', this.updateVisibleRegion);
564
- this.scrollClassAdder.attach();
565
- };
566
- }
567
- }, {
568
- kind: "field",
569
- key: "detachScrollListeners",
570
- value() {
571
- return () => {
572
- this.removeEventListener('scroll', this.updateVisibleRegion);
573
- this.scrollClassAdder.detach();
574
- };
575
- }
576
- }]
577
- };
578
- }, LitElement);
579
- customElements.define('br-mode-1up', Mode1UpLit);
@@ -1,106 +0,0 @@
1
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
2
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
3
- // @ts-check
4
- import { Mode2UpLit } from './Mode2UpLit.js';
5
- import { DragScrollable } from './DragScrollable.js';
6
- /** @typedef {import('../BookReader.js').default} BookReader */
7
- /** @typedef {import('./BookModel.js').BookModel} BookModel */
8
- /** @typedef {import('./BookModel.js').PageIndex} PageIndex */
9
-
10
- export class Mode2Up {
11
- /**
12
- * @param {BookReader} br
13
- * @param {BookModel} bookModel
14
- */
15
- constructor(br, bookModel) {
16
- this.br = br;
17
- this.book = bookModel;
18
- this.mode2UpLit = new Mode2UpLit(bookModel, br);
19
- this.mode2UpLit.flipSpeed = br.flipSpeed;
20
-
21
- /** @private */
22
- this.$el = $(this.mode2UpLit).attr('autoFit', this.br.options.twoPage.autofit)
23
- // We CANNOT use `br-mode-2up` as a class, because it's the same
24
- // as the name of the web component, and the webcomponents polyfill
25
- // uses the name of component as a class for style scoping 😒
26
- .addClass('br-mode-2up__root BRmode2up');
27
-
28
- /** Has mode2up ever been rendered before? */
29
- this.everShown = false;
30
- }
31
-
32
- /**
33
- * This is called when we switch into this mode
34
- */
35
- prepare() {
36
- var _this = this;
37
- var startLeaf = this.br.currentIndex();
38
- this.br.refs.$brContainer.empty().css({
39
- overflow: 'hidden'
40
- }).append(this.$el);
41
- this.mode2UpLit.style.opacity = '0';
42
-
43
- // Need this in a setTimeout so that it happens after the browser has _actually_
44
- // appended the element to the DOM
45
- setTimeout(/*#__PURE__*/_asyncToGenerator(function* () {
46
- if (!_this.everShown) {
47
- _this.mode2UpLit.initFirstRender(startLeaf);
48
- _this.everShown = true;
49
- _this.mode2UpLit.requestUpdate();
50
- yield _this.mode2UpLit.updateComplete;
51
- new DragScrollable(_this.mode2UpLit, {
52
- preventDefault: true,
53
- dragSelector: '.br-mode-2up__book',
54
- // Only handle mouse events; let browser/HammerJS handle touch
55
- dragstart: 'mousedown',
56
- dragcontinue: 'mousemove',
57
- dragend: 'mouseup'
58
- });
59
- } else {
60
- yield _this.mode2UpLit.jumpToIndex(startLeaf, {
61
- smooth: false
62
- });
63
- _this.resizePageView();
64
- }
65
- _this.mode2UpLit.style.opacity = '1';
66
- }));
67
- this.br.updateBrClasses();
68
- }
69
-
70
- /**
71
- * BREAKING CHANGE: No longer supports pageX/pageY
72
- * @param {PageIndex} index
73
- * @param {number} [pageX] x position on the page (in pixels) to center on
74
- * @param {number} [pageY] y position on the page (in pixels) to center on
75
- * @param {boolean} [noAnimate]
76
- */
77
- jumpToIndex(index, pageX, pageY, noAnimate) {
78
- this.mode2UpLit.jumpToIndex(index);
79
- }
80
-
81
- /**
82
- * @param {'in' | 'out'} direction
83
- */
84
- zoom(direction) {
85
- switch (direction) {
86
- case 'in':
87
- this.mode2UpLit.zoomIn();
88
- break;
89
- case 'out':
90
- this.mode2UpLit.zoomOut();
91
- break;
92
- default:
93
- console.error("Unsupported direction: ".concat(direction));
94
- }
95
- }
96
- resizePageView() {
97
- this.mode2UpLit.htmlDimensionsCacher.updateClientSizes();
98
- if (this.mode2UpLit.scale < this.mode2UpLit.initialScale && this.mode2UpLit.autoFit == 'none') {
99
- this.mode2UpLit.autoFit = 'auto';
100
- }
101
- if (this.mode2UpLit.autoFit != 'none') {
102
- this.mode2UpLit.resizeViaAutofit();
103
- }
104
- this.mode2UpLit.recenter();
105
- }
106
- }