@internetarchive/bookreader 5.0.0-88-alpha.7 → 5.0.0-88-alpha.9
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.
- package/babel.config.js +30 -12
- package/dist/esm/BookNavigator/assets/bookmark-colors.js +4 -0
- package/dist/esm/BookNavigator/assets/button-base.js +4 -0
- package/dist/esm/BookNavigator/assets/ia-logo.js +4 -0
- package/dist/esm/BookNavigator/assets/icon_checkmark.js +8 -0
- package/dist/esm/BookNavigator/assets/icon_close.js +4 -0
- package/dist/esm/BookNavigator/book-navigator.js +612 -0
- package/dist/esm/BookNavigator/bookmarks/bookmark-button.js +35 -0
- package/dist/esm/BookNavigator/bookmarks/bookmark-edit.js +78 -0
- package/dist/esm/BookNavigator/bookmarks/bookmarks-list.js +160 -0
- package/dist/esm/BookNavigator/bookmarks/bookmarks-loginCTA.js +24 -0
- package/dist/esm/BookNavigator/bookmarks/bookmarks-provider.js +55 -0
- package/dist/esm/BookNavigator/bookmarks/ia-bookmarks.js +521 -0
- package/dist/esm/BookNavigator/delete-modal-actions.js +29 -0
- package/dist/esm/BookNavigator/downloads/downloads-provider.js +84 -0
- package/dist/esm/BookNavigator/downloads/downloads.js +69 -0
- package/dist/esm/BookNavigator/search/search-provider.js +238 -0
- package/dist/esm/BookNavigator/search/search-results.js +161 -0
- package/dist/esm/BookNavigator/sharing.js +26 -0
- package/dist/esm/BookNavigator/viewable-files.js +94 -0
- package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments-provider.js +83 -0
- package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments.js +131 -0
- package/dist/esm/BookReader/BookModel.js +575 -0
- package/dist/esm/BookReader/DragScrollable.js +224 -0
- package/dist/esm/BookReader/ImageCache.js +122 -0
- package/dist/esm/BookReader/Mode1Up.js +114 -0
- package/dist/esm/BookReader/Mode1UpLit.js +579 -0
- package/dist/esm/BookReader/Mode2Up.js +106 -0
- package/dist/esm/BookReader/Mode2UpLit.js +1020 -0
- package/dist/esm/BookReader/ModeCoordinateSpace.js +28 -0
- package/dist/esm/BookReader/ModeSmoothZoom.js +318 -0
- package/dist/esm/BookReader/ModeThumb.js +366 -0
- package/dist/esm/BookReader/Navbar/Navbar.js +253 -0
- package/dist/esm/BookReader/PageContainer.js +165 -0
- package/dist/esm/BookReader/ReduceSet.js +27 -0
- package/dist/esm/BookReader/Toolbar/Toolbar.js +242 -0
- package/dist/esm/BookReader/events.js +20 -0
- package/dist/esm/BookReader/options.js +331 -0
- package/dist/esm/BookReader/utils/HTMLDimensionsCacher.js +48 -0
- package/dist/esm/BookReader/utils/ScrollClassAdder.js +31 -0
- package/dist/esm/BookReader/utils/SelectionObserver.js +42 -0
- package/dist/esm/BookReader/utils/classes.js +37 -0
- package/dist/esm/BookReader/utils.js +315 -0
- package/dist/esm/BookReader.js +1827 -0
- package/dist/esm/assets/icons/1up.svg +12 -0
- package/dist/esm/assets/icons/2up.svg +15 -0
- package/dist/esm/assets/icons/advance.svg +26 -0
- package/dist/esm/assets/icons/chevron-right.svg +1 -0
- package/dist/esm/assets/icons/close-circle-dark.svg +1 -0
- package/dist/esm/assets/icons/close-circle.svg +1 -0
- package/dist/esm/assets/icons/fullscreen.svg +17 -0
- package/dist/esm/assets/icons/fullscreen_exit.svg +17 -0
- package/dist/esm/assets/icons/hamburger.svg +15 -0
- package/dist/esm/assets/icons/left-arrow.svg +12 -0
- package/dist/esm/assets/icons/magnify-minus.svg +12 -0
- package/dist/esm/assets/icons/magnify-plus.svg +13 -0
- package/dist/esm/assets/icons/magnify.svg +15 -0
- package/dist/esm/assets/icons/pause.svg +23 -0
- package/dist/esm/assets/icons/play.svg +22 -0
- package/dist/esm/assets/icons/playback-speed.svg +34 -0
- package/dist/esm/assets/icons/read-aloud.svg +22 -0
- package/dist/esm/assets/icons/review.svg +22 -0
- package/dist/esm/assets/icons/thumbnails.svg +17 -0
- package/dist/esm/assets/icons/voice.svg +1 -0
- package/dist/esm/assets/icons/volume-full.svg +22 -0
- package/dist/esm/assets/images/BRicons.png +0 -0
- package/dist/esm/assets/images/BRicons.svg +94 -0
- package/dist/esm/assets/images/BRicons_ia.png +0 -0
- package/dist/esm/assets/images/back_pages.png +0 -0
- package/dist/esm/assets/images/book_bottom_icon.png +0 -0
- package/dist/esm/assets/images/book_down_icon.png +0 -0
- package/dist/esm/assets/images/book_left_icon.png +0 -0
- package/dist/esm/assets/images/book_leftmost_icon.png +0 -0
- package/dist/esm/assets/images/book_right_icon.png +0 -0
- package/dist/esm/assets/images/book_rightmost_icon.png +0 -0
- package/dist/esm/assets/images/book_top_icon.png +0 -0
- package/dist/esm/assets/images/book_up_icon.png +0 -0
- package/dist/esm/assets/images/books_graphic.svg +177 -0
- package/dist/esm/assets/images/booksplit.png +0 -0
- package/dist/esm/assets/images/control_pause_icon.png +0 -0
- package/dist/esm/assets/images/control_play_icon.png +0 -0
- package/dist/esm/assets/images/embed_icon.png +0 -0
- package/dist/esm/assets/images/icon-home-ia.png +0 -0
- package/dist/esm/assets/images/icon_OL-logo-xs.png +0 -0
- package/dist/esm/assets/images/icon_alert-xs.png +0 -0
- package/dist/esm/assets/images/icon_book.svg +12 -0
- package/dist/esm/assets/images/icon_bookmark.svg +12 -0
- package/dist/esm/assets/images/icon_close-pop.png +0 -0
- package/dist/esm/assets/images/icon_download.png +0 -0
- package/dist/esm/assets/images/icon_gear.svg +14 -0
- package/dist/esm/assets/images/icon_hamburger.svg +20 -0
- package/dist/esm/assets/images/icon_home.png +0 -0
- package/dist/esm/assets/images/icon_home.svg +21 -0
- package/dist/esm/assets/images/icon_home_ia.png +0 -0
- package/dist/esm/assets/images/icon_indicator.png +0 -0
- package/dist/esm/assets/images/icon_info.svg +11 -0
- package/dist/esm/assets/images/icon_one_page.svg +8 -0
- package/dist/esm/assets/images/icon_pause.svg +1 -0
- package/dist/esm/assets/images/icon_play.svg +1 -0
- package/dist/esm/assets/images/icon_playback-rate.svg +15 -0
- package/dist/esm/assets/images/icon_return.png +0 -0
- package/dist/esm/assets/images/icon_search_button.svg +8 -0
- package/dist/esm/assets/images/icon_share.svg +9 -0
- package/dist/esm/assets/images/icon_skip-ahead.svg +6 -0
- package/dist/esm/assets/images/icon_skip-back.svg +13 -0
- package/dist/esm/assets/images/icon_speaker.svg +18 -0
- package/dist/esm/assets/images/icon_speaker_open.svg +10 -0
- package/dist/esm/assets/images/icon_thumbnails.svg +12 -0
- package/dist/esm/assets/images/icon_toc.svg +5 -0
- package/dist/esm/assets/images/icon_two_pages.svg +9 -0
- package/dist/esm/assets/images/icon_zoomer.png +0 -0
- package/dist/esm/assets/images/loading.gif +0 -0
- package/dist/esm/assets/images/logo_icon.png +0 -0
- package/dist/esm/assets/images/marker_chap-off.png +0 -0
- package/dist/esm/assets/images/marker_chap-off.svg +11 -0
- package/dist/esm/assets/images/marker_chap-off_ia.png +0 -0
- package/dist/esm/assets/images/marker_chap-on.png +0 -0
- package/dist/esm/assets/images/marker_chap-on.svg +11 -0
- package/dist/esm/assets/images/marker_srch-on.svg +11 -0
- package/dist/esm/assets/images/marker_srchchap-off.png +0 -0
- package/dist/esm/assets/images/marker_srchchap-on.png +0 -0
- package/dist/esm/assets/images/nav_control-dn.png +0 -0
- package/dist/esm/assets/images/nav_control-dn_ia.png +0 -0
- package/dist/esm/assets/images/nav_control-up.png +0 -0
- package/dist/esm/assets/images/nav_control-up_ia.png +0 -0
- package/dist/esm/assets/images/nav_control.png +0 -0
- package/dist/esm/assets/images/one_page_mode_icon.png +0 -0
- package/dist/esm/assets/images/paper-badge.png +0 -0
- package/dist/esm/assets/images/print_icon.png +0 -0
- package/dist/esm/assets/images/progressbar.gif +0 -0
- package/dist/esm/assets/images/right_edges.png +0 -0
- package/dist/esm/assets/images/slider.png +0 -0
- package/dist/esm/assets/images/slider_ia.png +0 -0
- package/dist/esm/assets/images/thumbnail_mode_icon.png +0 -0
- package/dist/esm/assets/images/transparent.png +0 -0
- package/dist/esm/assets/images/two_page_mode_icon.png +0 -0
- package/dist/esm/assets/images/unviewable_page.png +0 -0
- package/dist/esm/assets/images/zoom_in_icon.png +0 -0
- package/dist/esm/assets/images/zoom_out_icon.png +0 -0
- package/dist/esm/css/BookReader.scss +85 -0
- package/dist/esm/css/_BRBookmarks.scss +29 -0
- package/dist/esm/css/_BRComponent.scss +13 -0
- package/dist/esm/css/_BRfloat.scss +197 -0
- package/dist/esm/css/_BRicon.scss +54 -0
- package/dist/esm/css/_BRmain.scss +262 -0
- package/dist/esm/css/_BRnav.scss +354 -0
- package/dist/esm/css/_BRpages.scss +213 -0
- package/dist/esm/css/_BRsearch.scss +268 -0
- package/dist/esm/css/_BRtoolbar.scss +84 -0
- package/dist/esm/css/_BRvendor.scss +5 -0
- package/dist/esm/css/_TextSelection.scss +108 -0
- package/dist/esm/css/_colorbox.scss +52 -0
- package/dist/esm/css/_controls.scss +257 -0
- package/dist/esm/css/_icons.scss +121 -0
- package/dist/esm/ia-bookreader/ia-bookreader.js +141 -0
- package/dist/esm/jquery-wrapper.js +3 -0
- package/dist/esm/plugins/plugin.archive_analytics.js +72 -0
- package/dist/esm/plugins/plugin.autoplay.js +119 -0
- package/dist/esm/plugins/plugin.chapters.js +288 -0
- package/dist/esm/plugins/plugin.iframe.js +44 -0
- package/dist/esm/plugins/plugin.iiif.js +146 -0
- package/dist/esm/plugins/plugin.resume.js +66 -0
- package/dist/esm/plugins/plugin.text_selection.js +621 -0
- package/dist/esm/plugins/plugin.vendor-fullscreen.js +227 -0
- package/dist/esm/plugins/search/plugin.search.js +499 -0
- package/dist/esm/plugins/search/utils.js +42 -0
- package/dist/esm/plugins/search/view.js +360 -0
- package/dist/esm/plugins/tts/AbstractTTSEngine.js +282 -0
- package/dist/esm/plugins/tts/FestivalTTSEngine.js +192 -0
- package/dist/esm/plugins/tts/PageChunk.js +105 -0
- package/dist/esm/plugins/tts/PageChunkIterator.js +155 -0
- package/dist/esm/plugins/tts/WebTTSEngine.js +364 -0
- package/dist/esm/plugins/tts/plugin.tts.js +315 -0
- package/dist/esm/plugins/tts/tooltip_dict.js +14 -0
- package/dist/esm/plugins/tts/utils.js +79 -0
- package/dist/esm/plugins/url/UrlPlugin.js +197 -0
- package/dist/esm/plugins/url/plugin.url.js +212 -0
- package/dist/esm/util/browserSniffing.js +56 -0
- package/dist/esm/util/debouncer.js +25 -0
- package/dist/esm/util/docCookies.js +75 -0
- package/dist/esm/util/strings.js +34 -0
- package/jsconfig.json +1 -0
- package/package.json +13 -6
@@ -0,0 +1,579 @@
|
|
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);
|
@@ -0,0 +1,106 @@
|
|
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
|
+
}
|