@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,1020 @@
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
2
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
3
|
+
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); }
|
4
|
+
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); }); }; }
|
5
|
+
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); }
|
6
|
+
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; }
|
7
|
+
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; }
|
8
|
+
function _coalesceGetterSetter(e, r) { void 0 !== e.descriptor.get ? r.descriptor.get = e.descriptor.get : r.descriptor.set = e.descriptor.set; }
|
9
|
+
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; }
|
10
|
+
function _hasDecorators(e) { return e.decorators && e.decorators.length; }
|
11
|
+
function _isDataDescriptor(e) { return void 0 !== e && !(void 0 === e.value && void 0 === e.writable); }
|
12
|
+
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; }
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
14
|
+
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); }
|
15
|
+
function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
|
16
|
+
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."); }
|
17
|
+
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; } }
|
18
|
+
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; }
|
19
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
20
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
21
|
+
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; }
|
22
|
+
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); }
|
23
|
+
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
24
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
25
|
+
// @ts-check
|
26
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
27
|
+
import { LitElement, html } from 'lit';
|
28
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
29
|
+
import { ModeSmoothZoom } from './ModeSmoothZoom';
|
30
|
+
import { arrChanged, promisifyEvent } from './utils';
|
31
|
+
import { HTMLDimensionsCacher } from "./utils/HTMLDimensionsCacher";
|
32
|
+
import { PageModel } from './BookModel';
|
33
|
+
import { ModeCoordinateSpace } from './ModeCoordinateSpace';
|
34
|
+
/** @typedef {import('./BookModel').BookModel} BookModel */
|
35
|
+
/** @typedef {import('./BookModel').PageIndex} PageIndex */
|
36
|
+
/** @typedef {import('./ModeSmoothZoom').SmoothZoomable} SmoothZoomable */
|
37
|
+
/** @typedef {import('./PageContainer').PageContainer} PageContainer */
|
38
|
+
/** @typedef {import('../BookReader').default} BookReader */
|
39
|
+
|
40
|
+
// I _have_ to make this globally public, otherwise it won't let me call
|
41
|
+
// its constructor :/
|
42
|
+
/** @implements {SmoothZoomable} */
|
43
|
+
export var Mode2UpLit = _decorate(null, function (_initialize, _LitElement) {
|
44
|
+
class Mode2UpLit extends _LitElement {
|
45
|
+
/****************************************/
|
46
|
+
/************** PROPERTIES **************/
|
47
|
+
/****************************************/
|
48
|
+
|
49
|
+
/** @type {BookReader} */
|
50
|
+
|
51
|
+
/************** BOOK-RELATED PROPERTIES **************/
|
52
|
+
|
53
|
+
/** @type {BookModel} */
|
54
|
+
|
55
|
+
/************** SCALE-RELATED PROPERTIES **************/
|
56
|
+
|
57
|
+
/** @type {ModeCoordinateSpace} Manage conversion between coordinates */
|
58
|
+
|
59
|
+
/** @type {import('./options').AutoFitValues} */
|
60
|
+
|
61
|
+
/************** VIRTUAL-FLIPPING PROPERTIES **************/
|
62
|
+
|
63
|
+
/** ms for flip animation */
|
64
|
+
|
65
|
+
/** @type {PageModel[]} */
|
66
|
+
|
67
|
+
/** @type {PageModel | null} */
|
68
|
+
|
69
|
+
/** @type {PageModel | null} */
|
70
|
+
|
71
|
+
/** @type {PageModel[]} */
|
72
|
+
|
73
|
+
/** @type {Record<PageIndex, PageContainer>} position in inches */
|
74
|
+
|
75
|
+
/** @type {{ direction: 'left' | 'right', pagesFlipping: [PageIndex, PageIndex], pagesFlippingCount: number }} */
|
76
|
+
|
77
|
+
/** @private cache this value */
|
78
|
+
|
79
|
+
/************** DOM-RELATED PROPERTIES **************/
|
80
|
+
|
81
|
+
/** @type {HTMLElement} */
|
82
|
+
|
83
|
+
/** @type {HTMLElement} */
|
84
|
+
|
85
|
+
/** @type {HTMLElement} */
|
86
|
+
|
87
|
+
/** @param {PageModel} page */
|
88
|
+
|
89
|
+
/** @param {PageModel} page */
|
90
|
+
|
91
|
+
/**
|
92
|
+
* @param {PageModel | null} pageLeft
|
93
|
+
* @param {PageModel | null} pageRight
|
94
|
+
*/
|
95
|
+
|
96
|
+
/** @type {HTMLDimensionsCacher} Cache things like clientWidth to reduce repaints */
|
97
|
+
|
98
|
+
/************** CONSTANT PROPERTIES **************/
|
99
|
+
|
100
|
+
/** How much to zoom when zoom button pressed */
|
101
|
+
|
102
|
+
/** How thick a page is in the real world, as an estimate for the leafs */
|
103
|
+
|
104
|
+
/****************************************/
|
105
|
+
/************** PUBLIC API **************/
|
106
|
+
/****************************************/
|
107
|
+
|
108
|
+
/************** MAIN PUBLIC METHODS **************/
|
109
|
+
|
110
|
+
/**
|
111
|
+
* @param {PageIndex} index
|
112
|
+
* TODO Remove smooth option from everywhere.
|
113
|
+
*/
|
114
|
+
|
115
|
+
/********************************************/
|
116
|
+
/************** INTERNAL STUFF **************/
|
117
|
+
/********************************************/
|
118
|
+
|
119
|
+
/************** LIFE CYCLE **************/
|
120
|
+
|
121
|
+
/**
|
122
|
+
* @param {BookModel} book
|
123
|
+
* @param {BookReader} br
|
124
|
+
*/
|
125
|
+
constructor(book, br) {
|
126
|
+
super();
|
127
|
+
_initialize(this);
|
128
|
+
this.book = book;
|
129
|
+
|
130
|
+
/** @type {BookReader} */
|
131
|
+
this.br = br;
|
132
|
+
}
|
133
|
+
|
134
|
+
/** @override */
|
135
|
+
|
136
|
+
/** @override */
|
137
|
+
|
138
|
+
/** @override */
|
139
|
+
|
140
|
+
/** @override */
|
141
|
+
|
142
|
+
/************** LIT CONFIGS **************/
|
143
|
+
|
144
|
+
/** @override */
|
145
|
+
|
146
|
+
/************** RENDERING **************/
|
147
|
+
|
148
|
+
/** @override */
|
149
|
+
|
150
|
+
/** @param {PageModel} page */
|
151
|
+
|
152
|
+
/**
|
153
|
+
* @param {PageIndex} startIndex
|
154
|
+
*/
|
155
|
+
|
156
|
+
/** @param {PageModel} page */
|
157
|
+
|
158
|
+
/**
|
159
|
+
* @param {'left' | 'right'} side
|
160
|
+
* Renders the current leaf edges, as well as any "moving" leaf edges,
|
161
|
+
* i.e. leaf edges that are currently being flipped. Uses a custom element
|
162
|
+
* to render br-leaf-edges.
|
163
|
+
**/
|
164
|
+
|
165
|
+
/**
|
166
|
+
* @returns {PageModel[]}
|
167
|
+
*/
|
168
|
+
|
169
|
+
/**
|
170
|
+
* @param {PageModel} page
|
171
|
+
* @param {import('./options').AutoFitValues} autoFit
|
172
|
+
*/
|
173
|
+
|
174
|
+
/**
|
175
|
+
* @param {PageModel} page
|
176
|
+
* @param {number} scale
|
177
|
+
* @returns {{x: number, y: number}}
|
178
|
+
*/
|
179
|
+
|
180
|
+
/************** VIRTUAL FLIPPING LOGIC **************/
|
181
|
+
|
182
|
+
/**
|
183
|
+
* @param {'left' | 'right' | 'next' | 'prev' | PageIndex | PageModel | {left: PageModel | null, right: PageModel | null}} nextSpread
|
184
|
+
*/
|
185
|
+
|
186
|
+
/**
|
187
|
+
* @param {'left' | 'right' | 'next' | 'prev' | PageIndex | PageModel | {left: PageModel | null, right: PageModel | null}} nextSpread
|
188
|
+
* @returns {{left: PageModel | null, right: PageModel | null}}
|
189
|
+
*/
|
190
|
+
|
191
|
+
/************** INPUT HANDLERS **************/
|
192
|
+
|
193
|
+
/**
|
194
|
+
* @param {MouseEvent} ev
|
195
|
+
*/
|
196
|
+
}
|
197
|
+
return {
|
198
|
+
F: Mode2UpLit,
|
199
|
+
d: [{
|
200
|
+
kind: "field",
|
201
|
+
key: "br",
|
202
|
+
value: void 0
|
203
|
+
}, {
|
204
|
+
kind: "field",
|
205
|
+
decorators: [property({
|
206
|
+
type: Object
|
207
|
+
})],
|
208
|
+
key: "book",
|
209
|
+
value: void 0
|
210
|
+
}, {
|
211
|
+
kind: "field",
|
212
|
+
key: "coordSpace",
|
213
|
+
value() {
|
214
|
+
return new ModeCoordinateSpace(this);
|
215
|
+
}
|
216
|
+
}, {
|
217
|
+
kind: "field",
|
218
|
+
decorators: [property({
|
219
|
+
type: Number
|
220
|
+
})],
|
221
|
+
key: "scale",
|
222
|
+
value() {
|
223
|
+
return 1;
|
224
|
+
}
|
225
|
+
}, {
|
226
|
+
kind: "field",
|
227
|
+
key: "initialScale",
|
228
|
+
value() {
|
229
|
+
return 1;
|
230
|
+
}
|
231
|
+
}, {
|
232
|
+
kind: "field",
|
233
|
+
decorators: [property({
|
234
|
+
type: String
|
235
|
+
})],
|
236
|
+
key: "autoFit",
|
237
|
+
value() {
|
238
|
+
return 'auto';
|
239
|
+
}
|
240
|
+
}, {
|
241
|
+
kind: "field",
|
242
|
+
key: "flipSpeed",
|
243
|
+
value() {
|
244
|
+
return 400;
|
245
|
+
}
|
246
|
+
}, {
|
247
|
+
kind: "field",
|
248
|
+
decorators: [query('.br-mode-2up__leafs--flipping')],
|
249
|
+
key: "$flippingEdges",
|
250
|
+
value: void 0
|
251
|
+
}, {
|
252
|
+
kind: "field",
|
253
|
+
decorators: [property({
|
254
|
+
type: Array,
|
255
|
+
hasChanged: arrChanged
|
256
|
+
})],
|
257
|
+
key: "visiblePages",
|
258
|
+
value() {
|
259
|
+
return [];
|
260
|
+
}
|
261
|
+
}, {
|
262
|
+
kind: "get",
|
263
|
+
key: "pageLeft",
|
264
|
+
value: function value() {
|
265
|
+
return this.visiblePages.find(p => p.pageSide == 'L');
|
266
|
+
}
|
267
|
+
}, {
|
268
|
+
kind: "get",
|
269
|
+
key: "pageRight",
|
270
|
+
value: function value() {
|
271
|
+
return this.visiblePages.find(p => p.pageSide == 'R');
|
272
|
+
}
|
273
|
+
}, {
|
274
|
+
kind: "field",
|
275
|
+
decorators: [property({
|
276
|
+
type: Array
|
277
|
+
})],
|
278
|
+
key: "renderedPages",
|
279
|
+
value() {
|
280
|
+
return [];
|
281
|
+
}
|
282
|
+
}, {
|
283
|
+
kind: "field",
|
284
|
+
key: "pageContainerCache",
|
285
|
+
value() {
|
286
|
+
return {};
|
287
|
+
}
|
288
|
+
}, {
|
289
|
+
kind: "field",
|
290
|
+
key: "activeFlip",
|
291
|
+
value() {
|
292
|
+
return null;
|
293
|
+
}
|
294
|
+
}, {
|
295
|
+
kind: "field",
|
296
|
+
key: "_leftCoverWidth",
|
297
|
+
value() {
|
298
|
+
return 0;
|
299
|
+
}
|
300
|
+
}, {
|
301
|
+
kind: "get",
|
302
|
+
key: "$container",
|
303
|
+
value: function value() {
|
304
|
+
return this;
|
305
|
+
}
|
306
|
+
}, {
|
307
|
+
kind: "get",
|
308
|
+
key: "$visibleWorld",
|
309
|
+
value: function value() {
|
310
|
+
return this.$book;
|
311
|
+
}
|
312
|
+
}, {
|
313
|
+
kind: "field",
|
314
|
+
decorators: [query('.br-mode-2up__book')],
|
315
|
+
key: "$book",
|
316
|
+
value: void 0
|
317
|
+
}, {
|
318
|
+
kind: "get",
|
319
|
+
key: "positions",
|
320
|
+
value: function value() {
|
321
|
+
return this.computePositions(this.pageLeft, this.pageRight);
|
322
|
+
}
|
323
|
+
}, {
|
324
|
+
kind: "method",
|
325
|
+
key: "computePageHeight",
|
326
|
+
value: function computePageHeight(page) {
|
327
|
+
return this.book.getMedianPageSizeInches().height;
|
328
|
+
}
|
329
|
+
}, {
|
330
|
+
kind: "method",
|
331
|
+
key: "computePageWidth",
|
332
|
+
value: function computePageWidth(page) {
|
333
|
+
return page.widthInches * this.computePageHeight(page) / page.heightInches;
|
334
|
+
}
|
335
|
+
}, {
|
336
|
+
kind: "method",
|
337
|
+
key: "computePositions",
|
338
|
+
value: function computePositions(pageLeft, pageRight) {
|
339
|
+
var _pageLeft$index, _this$activeFlip, _pageRight$index, _this$activeFlip2;
|
340
|
+
var computePageWidth = this.computePageWidth.bind(this);
|
341
|
+
var numLeafs = this.book.getNumLeafs();
|
342
|
+
var movingPagesWidth = this.activeFlip ? Math.ceil(this.activeFlip.pagesFlippingCount / 2) * this.PAGE_THICKNESS_IN : 0;
|
343
|
+
var leftPagesCount = this.book.pageProgression == 'lr' ? (_pageLeft$index = pageLeft === null || pageLeft === void 0 ? void 0 : pageLeft.index) !== null && _pageLeft$index !== void 0 ? _pageLeft$index : 0 : !pageLeft ? 0 : numLeafs - pageLeft.index;
|
344
|
+
|
345
|
+
// Everything is relative to the gutter
|
346
|
+
var gutter = this._leftCoverWidth + leftPagesCount * this.PAGE_THICKNESS_IN;
|
347
|
+
var pageLeftEnd = gutter;
|
348
|
+
var pageLeftWidth = !pageLeft ? computePageWidth(pageRight.right) : computePageWidth(pageLeft);
|
349
|
+
var pageLeftStart = gutter - pageLeftWidth;
|
350
|
+
var leafEdgesLeftEnd = pageLeftStart; // leafEdgesLeftStart + leafEdgesLeftMainWidth + leafEdgesLeftMovingWidth;
|
351
|
+
var leafEdgesLeftMovingWidth = ((_this$activeFlip = this.activeFlip) === null || _this$activeFlip === void 0 ? void 0 : _this$activeFlip.direction) != 'left' ? 0 : movingPagesWidth;
|
352
|
+
var leafEdgesLeftMainWidth = Math.ceil(leftPagesCount / 2) * this.PAGE_THICKNESS_IN - leafEdgesLeftMovingWidth;
|
353
|
+
var leafEdgesLeftFullWidth = leafEdgesLeftMovingWidth + leafEdgesLeftMainWidth;
|
354
|
+
var leafEdgesLeftMovingStart = leafEdgesLeftEnd - leafEdgesLeftMovingWidth;
|
355
|
+
var leafEdgesLeftStart = leafEdgesLeftMovingStart - leafEdgesLeftMainWidth;
|
356
|
+
var pageRightStart = gutter;
|
357
|
+
var pageRightWidth = !pageRight ? 0 : computePageWidth(pageRight);
|
358
|
+
var pageRightEnd = pageRightStart + pageRightWidth;
|
359
|
+
var rightPagesCount = this.book.pageProgression == 'lr' ? !pageRight ? 0 : numLeafs - pageRight.index : (_pageRight$index = pageRight === null || pageRight === void 0 ? void 0 : pageRight.index) !== null && _pageRight$index !== void 0 ? _pageRight$index : 0;
|
360
|
+
var leafEdgesRightStart = pageRightEnd;
|
361
|
+
var leafEdgesRightMovingWidth = ((_this$activeFlip2 = this.activeFlip) === null || _this$activeFlip2 === void 0 ? void 0 : _this$activeFlip2.direction) != 'right' ? 0 : movingPagesWidth;
|
362
|
+
var leafEdgesRightMainStart = leafEdgesRightStart + leafEdgesRightMovingWidth;
|
363
|
+
var leafEdgesRightMainWidth = Math.ceil(rightPagesCount / 2) * this.PAGE_THICKNESS_IN - leafEdgesRightMovingWidth;
|
364
|
+
var leafEdgesRightEnd = leafEdgesRightStart + leafEdgesRightMainWidth + leafEdgesRightMovingWidth;
|
365
|
+
var leafEdgesRightFullWidth = leafEdgesRightMovingWidth + leafEdgesRightMainWidth;
|
366
|
+
var spreadWidth = pageRightEnd - pageLeftStart;
|
367
|
+
var bookWidth = leafEdgesRightEnd - leafEdgesLeftStart;
|
368
|
+
return {
|
369
|
+
leafEdgesLeftStart,
|
370
|
+
leafEdgesLeftMainWidth,
|
371
|
+
leafEdgesLeftMovingStart,
|
372
|
+
leafEdgesLeftMovingWidth,
|
373
|
+
leafEdgesLeftEnd,
|
374
|
+
leafEdgesLeftFullWidth,
|
375
|
+
pageLeftStart,
|
376
|
+
pageLeftWidth,
|
377
|
+
pageLeftEnd,
|
378
|
+
gutter,
|
379
|
+
pageRightStart,
|
380
|
+
pageRightWidth,
|
381
|
+
pageRightEnd,
|
382
|
+
leafEdgesRightStart,
|
383
|
+
leafEdgesRightMovingWidth,
|
384
|
+
leafEdgesRightMainStart,
|
385
|
+
leafEdgesRightMainWidth,
|
386
|
+
leafEdgesRightEnd,
|
387
|
+
leafEdgesRightFullWidth,
|
388
|
+
spreadWidth,
|
389
|
+
bookWidth
|
390
|
+
};
|
391
|
+
}
|
392
|
+
}, {
|
393
|
+
kind: "field",
|
394
|
+
key: "htmlDimensionsCacher",
|
395
|
+
value() {
|
396
|
+
return new HTMLDimensionsCacher(this);
|
397
|
+
}
|
398
|
+
}, {
|
399
|
+
kind: "field",
|
400
|
+
key: "smoothZoomer",
|
401
|
+
value() {
|
402
|
+
return new ModeSmoothZoom(this);
|
403
|
+
}
|
404
|
+
}, {
|
405
|
+
kind: "field",
|
406
|
+
key: "ZOOM_FACTOR",
|
407
|
+
value() {
|
408
|
+
return 1.1;
|
409
|
+
}
|
410
|
+
}, {
|
411
|
+
kind: "field",
|
412
|
+
key: "PAGE_THICKNESS_IN",
|
413
|
+
value() {
|
414
|
+
return 0.002;
|
415
|
+
}
|
416
|
+
}, {
|
417
|
+
kind: "method",
|
418
|
+
key: "jumpToIndex",
|
419
|
+
value: (function () {
|
420
|
+
var _jumpToIndex = _asyncToGenerator(function* (index) {
|
421
|
+
var {
|
422
|
+
smooth = true
|
423
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
424
|
+
yield this.flipAnimation(index, {
|
425
|
+
animate: smooth
|
426
|
+
});
|
427
|
+
});
|
428
|
+
function jumpToIndex(_x) {
|
429
|
+
return _jumpToIndex.apply(this, arguments);
|
430
|
+
}
|
431
|
+
return jumpToIndex;
|
432
|
+
}())
|
433
|
+
}, {
|
434
|
+
kind: "method",
|
435
|
+
key: "zoomIn",
|
436
|
+
value: function zoomIn() {
|
437
|
+
this.scale *= this.ZOOM_FACTOR;
|
438
|
+
}
|
439
|
+
}, {
|
440
|
+
kind: "method",
|
441
|
+
key: "zoomOut",
|
442
|
+
value: function zoomOut() {
|
443
|
+
this.scale *= 1 / this.ZOOM_FACTOR;
|
444
|
+
}
|
445
|
+
}, {
|
446
|
+
kind: "method",
|
447
|
+
key: "firstUpdated",
|
448
|
+
value: function firstUpdated(changedProps) {
|
449
|
+
_superPropGet(Mode2UpLit, "firstUpdated", this, 3)([changedProps]);
|
450
|
+
this.htmlDimensionsCacher.updateClientSizes();
|
451
|
+
this.smoothZoomer.attach();
|
452
|
+
}
|
453
|
+
}, {
|
454
|
+
kind: "method",
|
455
|
+
key: "connectedCallback",
|
456
|
+
value: function connectedCallback() {
|
457
|
+
_superPropGet(Mode2UpLit, "connectedCallback", this, 3)([]);
|
458
|
+
this.htmlDimensionsCacher.attachResizeListener();
|
459
|
+
this.smoothZoomer.attach();
|
460
|
+
}
|
461
|
+
}, {
|
462
|
+
kind: "method",
|
463
|
+
key: "disconnectedCallback",
|
464
|
+
value: function disconnectedCallback() {
|
465
|
+
this.htmlDimensionsCacher.detachResizeListener();
|
466
|
+
this.smoothZoomer.detach();
|
467
|
+
_superPropGet(Mode2UpLit, "disconnectedCallback", this, 3)([]);
|
468
|
+
}
|
469
|
+
}, {
|
470
|
+
kind: "method",
|
471
|
+
key: "updated",
|
472
|
+
value: function updated(changedProps) {
|
473
|
+
// this.X is the new value
|
474
|
+
// changedProps.get('X') is the old value
|
475
|
+
if (changedProps.has('book')) {
|
476
|
+
this._leftCoverWidth = this.computePageWidth(this.book.getPage(this.book.pageProgression == 'lr' ? 0 : -1));
|
477
|
+
}
|
478
|
+
if (changedProps.has('visiblePages')) {
|
479
|
+
this.renderedPages = this.computeRenderedPages();
|
480
|
+
this.br.displayedIndices = this.visiblePages.map(p => p.index);
|
481
|
+
this.br.updateFirstIndex(this.br.displayedIndices[0]);
|
482
|
+
this.br._components.navbar.updateNavIndexThrottled();
|
483
|
+
}
|
484
|
+
if (changedProps.has('autoFit')) {
|
485
|
+
if (this.autoFit != 'none') {
|
486
|
+
this.resizeViaAutofit();
|
487
|
+
}
|
488
|
+
}
|
489
|
+
if (changedProps.has('scale')) {
|
490
|
+
var oldVal = changedProps.get('scale');
|
491
|
+
this.recenter();
|
492
|
+
this.smoothZoomer.updateViewportOnZoom(this.scale, oldVal);
|
493
|
+
}
|
494
|
+
}
|
495
|
+
}, {
|
496
|
+
kind: "method",
|
497
|
+
key: "createRenderRoot",
|
498
|
+
value: function createRenderRoot() {
|
499
|
+
// Disable shadow DOM; that would require a huge rejiggering of CSS
|
500
|
+
return this;
|
501
|
+
}
|
502
|
+
}, {
|
503
|
+
kind: "method",
|
504
|
+
key: "render",
|
505
|
+
value: function render() {
|
506
|
+
return html(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n <div class=\"br-mode-2up__book\" @mouseup=", ">\n ", "\n ", "\n ", "\n </div>"])), this.handlePageClick, this.renderLeafEdges('left'), this.renderedPages.map(p => this.renderPage(p)), this.renderLeafEdges('right'));
|
507
|
+
}
|
508
|
+
}, {
|
509
|
+
kind: "field",
|
510
|
+
key: "createPageContainer",
|
511
|
+
value() {
|
512
|
+
return page => {
|
513
|
+
return this.pageContainerCache[page.index] || (this.pageContainerCache[page.index] =
|
514
|
+
// @ts-ignore I know it's protected, TS! But Mode2Up and BookReader are friends.
|
515
|
+
this.br._createPageContainer(page.index));
|
516
|
+
};
|
517
|
+
}
|
518
|
+
}, {
|
519
|
+
kind: "method",
|
520
|
+
key: "initFirstRender",
|
521
|
+
value: function initFirstRender(startIndex) {
|
522
|
+
var page = this.book.getPage(startIndex);
|
523
|
+
var spread = page.spread;
|
524
|
+
this.visiblePages = (this.book.pageProgression == 'lr' ? [spread.left, spread.right] : [spread.right, spread.left]).filter(p => p);
|
525
|
+
this.htmlDimensionsCacher.updateClientSizes();
|
526
|
+
this.resizeViaAutofit(page);
|
527
|
+
this.initialScale = this.scale;
|
528
|
+
}
|
529
|
+
}, {
|
530
|
+
kind: "field",
|
531
|
+
key: "renderPage",
|
532
|
+
value() {
|
533
|
+
return page => {
|
534
|
+
var wToR = this.coordSpace.worldUnitsToRenderedPixels;
|
535
|
+
var wToV = this.coordSpace.worldUnitsToVisiblePixels;
|
536
|
+
var width = wToR(this.computePageWidth(page));
|
537
|
+
var height = wToR(this.computePageHeight(page));
|
538
|
+
var isVisible = this.visiblePages.map(p => p.index).includes(page.index);
|
539
|
+
var positions = this.computePositions(page.spread.left, page.spread.right);
|
540
|
+
var pageContainerEl = this.createPageContainer(page).update({
|
541
|
+
dimensions: {
|
542
|
+
width,
|
543
|
+
height,
|
544
|
+
top: 0,
|
545
|
+
left: wToR(page.pageSide == 'L' ? positions.pageLeftStart : positions.pageLeftEnd)
|
546
|
+
},
|
547
|
+
reduce: page.width / wToV(this.computePageWidth(page))
|
548
|
+
}).$container[0];
|
549
|
+
pageContainerEl.classList.toggle('BRpage-visible', isVisible);
|
550
|
+
return pageContainerEl;
|
551
|
+
};
|
552
|
+
}
|
553
|
+
}, {
|
554
|
+
kind: "field",
|
555
|
+
key: "renderLeafEdges",
|
556
|
+
value() {
|
557
|
+
return side => {
|
558
|
+
var _this$activeFlip3;
|
559
|
+
if (!this.visiblePages.length) return html(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral([""])));
|
560
|
+
var fullWidthIn = side == 'left' ? this.positions.leafEdgesLeftFullWidth : this.positions.leafEdgesRightFullWidth;
|
561
|
+
if (!fullWidthIn) return html(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([""])));
|
562
|
+
var wToR = this.coordSpace.worldUnitsToRenderedPixels;
|
563
|
+
var height = wToR(this.computePageHeight(this.visiblePages[0]));
|
564
|
+
var hasMovingPages = ((_this$activeFlip3 = this.activeFlip) === null || _this$activeFlip3 === void 0 ? void 0 : _this$activeFlip3.direction) == side;
|
565
|
+
var leftmostPage = this.book.getPage(this.book.pageProgression == 'lr' ? 0 : this.book.getNumLeafs() - 1);
|
566
|
+
var rightmostPage = this.book.getPage(this.book.pageProgression == 'lr' ? this.book.getNumLeafs() - 1 : 0);
|
567
|
+
var numPagesFlipping = hasMovingPages ? this.activeFlip.pagesFlippingCount : 0;
|
568
|
+
var range = side == 'left' ? [leftmostPage.index, this.pageLeft.goLeft(numPagesFlipping).index] : [this.pageRight.goRight(numPagesFlipping).index, rightmostPage.index];
|
569
|
+
var mainEdgesStyle = {
|
570
|
+
width: "".concat(wToR(side == 'left' ? this.positions.leafEdgesLeftMainWidth : this.positions.leafEdgesRightMainWidth), "px"),
|
571
|
+
height: "".concat(height, "px"),
|
572
|
+
left: "".concat(wToR(side == 'left' ? this.positions.leafEdgesLeftStart : this.positions.leafEdgesRightMainStart), "px")
|
573
|
+
};
|
574
|
+
var mainEdges = html(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n <br-leaf-edges\n leftIndex=", "\n rightIndex=", "\n .book=", "\n .pageClickHandler=", "\n side=", "\n class=\"br-mode-2up__leafs br-mode-2up__leafs--", "\"\n style=", "\n ></br-leaf-edges>\n "])), range[0], range[1], this.book, index => this.br.jumpToIndex(index), side, side, styleMap(mainEdgesStyle));
|
575
|
+
if (hasMovingPages) {
|
576
|
+
var width = wToR(side == 'left' ? this.positions.leafEdgesLeftMovingWidth : this.positions.leafEdgesRightMovingWidth);
|
577
|
+
var style = {
|
578
|
+
width: "".concat(width, "px"),
|
579
|
+
height: "".concat(height, "px"),
|
580
|
+
left: "".concat(wToR(side == 'left' ? this.positions.leafEdgesLeftMovingStart : this.positions.leafEdgesRightStart), "px"),
|
581
|
+
pointerEvents: 'none',
|
582
|
+
transformOrigin: "".concat(wToR(side == 'left' ? this.positions.pageLeftWidth : -this.positions.pageRightWidth) + width / 2, "px 0")
|
583
|
+
};
|
584
|
+
var movingEdges = html(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n <br-leaf-edges\n leftIndex=", "\n rightIndex=", "\n .book=", "\n side=", "\n class=\"br-mode-2up__leafs br-mode-2up__leafs--", " br-mode-2up__leafs--flipping\"\n style=", "\n ></br-leaf-edges>\n "])), this.activeFlip.pagesFlipping[0], this.activeFlip.pagesFlipping[1], this.book, side, side, styleMap(style));
|
585
|
+
return side == 'left' ? html(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", "", ""])), mainEdges, movingEdges) : html(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["", "", ""])), movingEdges, mainEdges);
|
586
|
+
} else {
|
587
|
+
return mainEdges;
|
588
|
+
}
|
589
|
+
};
|
590
|
+
}
|
591
|
+
}, {
|
592
|
+
kind: "method",
|
593
|
+
key: "resizeViaAutofit",
|
594
|
+
value: function resizeViaAutofit() {
|
595
|
+
var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.visiblePages[0];
|
596
|
+
this.scale = this.computeScale(page, this.autoFit);
|
597
|
+
}
|
598
|
+
}, {
|
599
|
+
kind: "method",
|
600
|
+
key: "recenter",
|
601
|
+
value: function recenter() {
|
602
|
+
var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.visiblePages[0];
|
603
|
+
var translate = this.computeTranslate(page, this.scale);
|
604
|
+
this.$book.style.transform = "translateX(".concat(translate.x, "px) translateY(").concat(translate.y, "px) scale(").concat(this.scale, ")");
|
605
|
+
}
|
606
|
+
}, {
|
607
|
+
kind: "method",
|
608
|
+
key: "computeRenderedPages",
|
609
|
+
value: function computeRenderedPages() {
|
610
|
+
var _this$visiblePages$, _this$visiblePages$2, _this$visiblePages, _this$visiblePages2;
|
611
|
+
// Also render 2 pages before/after
|
612
|
+
// @ts-ignore TS doesn't understand the filtering out of null values
|
613
|
+
return [(_this$visiblePages$ = this.visiblePages[0]) === null || _this$visiblePages$ === void 0 || (_this$visiblePages$ = _this$visiblePages$.prev) === null || _this$visiblePages$ === void 0 ? void 0 : _this$visiblePages$.prev, (_this$visiblePages$2 = this.visiblePages[0]) === null || _this$visiblePages$2 === void 0 ? void 0 : _this$visiblePages$2.prev, ...this.visiblePages, (_this$visiblePages = this.visiblePages[this.visiblePages.length - 1]) === null || _this$visiblePages === void 0 ? void 0 : _this$visiblePages.next, (_this$visiblePages2 = this.visiblePages[this.visiblePages.length - 1]) === null || _this$visiblePages2 === void 0 || (_this$visiblePages2 = _this$visiblePages2.next) === null || _this$visiblePages2 === void 0 ? void 0 : _this$visiblePages2.next].filter(p => p)
|
614
|
+
// Never render more than 10 pages! Usually means something is wrong
|
615
|
+
.slice(0, 10);
|
616
|
+
}
|
617
|
+
}, {
|
618
|
+
kind: "method",
|
619
|
+
key: "computeScale",
|
620
|
+
value: function computeScale(page, autoFit) {
|
621
|
+
if (!page) return 1;
|
622
|
+
var spread = page.spread;
|
623
|
+
var bookWidth = this.computePositions(spread.left, spread.right).bookWidth;
|
624
|
+
var bookHeight = this.computePageHeight(spread.left || spread.right);
|
625
|
+
var BOOK_PADDING_PX = 10;
|
626
|
+
var curScale = this.scale;
|
627
|
+
this.scale = 1; // Need this temporarily
|
628
|
+
var widthScale = this.coordSpace.renderedPixelsToWorldUnits(this.htmlDimensionsCacher.clientWidth - 2 * BOOK_PADDING_PX) / bookWidth;
|
629
|
+
var heightScale = this.coordSpace.renderedPixelsToWorldUnits(this.htmlDimensionsCacher.clientHeight - 2 * BOOK_PADDING_PX) / bookHeight;
|
630
|
+
this.scale = curScale;
|
631
|
+
var realScale = 1;
|
632
|
+
var scale = realScale;
|
633
|
+
if (autoFit == 'width') {
|
634
|
+
scale = widthScale;
|
635
|
+
} else if (autoFit == 'height') {
|
636
|
+
scale = heightScale;
|
637
|
+
} else if (autoFit == 'auto') {
|
638
|
+
scale = Math.min(widthScale, heightScale);
|
639
|
+
} else if (autoFit == 'none') {
|
640
|
+
scale = this.scale;
|
641
|
+
} else {
|
642
|
+
// Should be impossible
|
643
|
+
throw new Error("Invalid autoFit value: ".concat(autoFit));
|
644
|
+
}
|
645
|
+
return scale;
|
646
|
+
}
|
647
|
+
}, {
|
648
|
+
kind: "method",
|
649
|
+
key: "computeTranslate",
|
650
|
+
value: function computeTranslate(page) {
|
651
|
+
var scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.scale;
|
652
|
+
if (!page) return {
|
653
|
+
x: 0,
|
654
|
+
y: 0
|
655
|
+
};
|
656
|
+
var spread = page.spread;
|
657
|
+
// Default to real size if it fits, otherwise default to full height
|
658
|
+
var positions = this.computePositions(spread.left, spread.right);
|
659
|
+
var bookWidth = positions.bookWidth;
|
660
|
+
var bookHeight = this.computePageHeight(spread.left || spread.right);
|
661
|
+
var visibleBookWidth = this.coordSpace.worldUnitsToRenderedPixels(bookWidth) * scale;
|
662
|
+
var visibleBookHeight = this.coordSpace.worldUnitsToRenderedPixels(bookHeight) * scale;
|
663
|
+
var leftOffset = this.coordSpace.worldUnitsToRenderedPixels(-positions.leafEdgesLeftStart) * scale;
|
664
|
+
var translateX = (this.htmlDimensionsCacher.clientWidth - visibleBookWidth) / 2 + leftOffset;
|
665
|
+
var translateY = (this.htmlDimensionsCacher.clientHeight - visibleBookHeight) / 2;
|
666
|
+
return {
|
667
|
+
x: Math.max(leftOffset, translateX),
|
668
|
+
y: Math.max(0, translateY)
|
669
|
+
};
|
670
|
+
}
|
671
|
+
}, {
|
672
|
+
kind: "method",
|
673
|
+
key: "flipAnimation",
|
674
|
+
value: (function () {
|
675
|
+
var _flipAnimation = _asyncToGenerator(function* (nextSpread) {
|
676
|
+
var _ref, _curSpread$left$index, _curSpread$left, _nextSpread$left$inde, _nextSpread$left;
|
677
|
+
var {
|
678
|
+
animate = true
|
679
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
680
|
+
var curSpread = (_ref = this.pageLeft || this.pageRight) === null || _ref === void 0 ? void 0 : _ref.spread;
|
681
|
+
if (!curSpread) {
|
682
|
+
// Nothings been actually rendered yet! Will be corrected during initFirstRender
|
683
|
+
return;
|
684
|
+
}
|
685
|
+
nextSpread = this.parseNextSpread(nextSpread);
|
686
|
+
if (this.activeFlip || !nextSpread) return;
|
687
|
+
var progression = this.book.pageProgression;
|
688
|
+
var curLeftIndex = (_curSpread$left$index = (_curSpread$left = curSpread.left) === null || _curSpread$left === void 0 ? void 0 : _curSpread$left.index) !== null && _curSpread$left$index !== void 0 ? _curSpread$left$index : progression == 'lr' ? -1 : this.book.getNumLeafs();
|
689
|
+
var nextLeftIndex = (_nextSpread$left$inde = (_nextSpread$left = nextSpread.left) === null || _nextSpread$left === void 0 ? void 0 : _nextSpread$left.index) !== null && _nextSpread$left$inde !== void 0 ? _nextSpread$left$inde : progression == 'lr' ? -1 : this.book.getNumLeafs();
|
690
|
+
if (curLeftIndex == nextLeftIndex) return;
|
691
|
+
var renderedIndices = this.renderedPages.map(p => p.index);
|
692
|
+
/** @type {PageContainer[]} */
|
693
|
+
var nextPageContainers = [];
|
694
|
+
for (var page of [nextSpread.left, nextSpread.right]) {
|
695
|
+
if (!page) continue;
|
696
|
+
nextPageContainers.push(this.createPageContainer(page));
|
697
|
+
if (!renderedIndices.includes(page.index)) {
|
698
|
+
this.renderedPages.push(page);
|
699
|
+
}
|
700
|
+
}
|
701
|
+
var curTranslate = this.computeTranslate(curSpread.left || curSpread.right, this.scale);
|
702
|
+
var idealNextTranslate = this.computeTranslate(nextSpread.left || nextSpread.right, this.scale);
|
703
|
+
var translateDiff = Math.sqrt((idealNextTranslate.x - curTranslate.x) ** 2 + (idealNextTranslate.y - curTranslate.y) ** 2);
|
704
|
+
var nextTranslate = "translate(".concat(idealNextTranslate.x, "px, ").concat(idealNextTranslate.y, "px)");
|
705
|
+
if (translateDiff < 50) {
|
706
|
+
var _this$$book$style$tra;
|
707
|
+
var activeTranslate = (_this$$book$style$tra = this.$book.style.transform.match(/translate\([^)]+\)/)) === null || _this$$book$style$tra === void 0 ? void 0 : _this$$book$style$tra[0];
|
708
|
+
if (activeTranslate) {
|
709
|
+
nextTranslate = activeTranslate;
|
710
|
+
}
|
711
|
+
}
|
712
|
+
var newTransform = "".concat(nextTranslate, " scale(").concat(this.scale, ")");
|
713
|
+
if (animate && 'animate' in Element.prototype) {
|
714
|
+
// This table is used to determine the direction of the flip animation:
|
715
|
+
// | < | >
|
716
|
+
// lr | L | R
|
717
|
+
// rl | R | L
|
718
|
+
var direction = progression == 'lr' ? nextLeftIndex > curLeftIndex ? 'right' : 'left' : nextLeftIndex > curLeftIndex ? 'left' : 'right';
|
719
|
+
this.activeFlip = {
|
720
|
+
direction,
|
721
|
+
pagesFlipping: [curLeftIndex, nextLeftIndex],
|
722
|
+
pagesFlippingCount: Math.abs(nextLeftIndex - curLeftIndex)
|
723
|
+
};
|
724
|
+
this.classList.add("br-mode-2up--flipping-".concat(direction));
|
725
|
+
this.classList.add("BRpageFlipping");
|
726
|
+
|
727
|
+
// Wait for lit update cycle to finish so that entering pages are rendered
|
728
|
+
this.requestUpdate();
|
729
|
+
yield this.updateComplete;
|
730
|
+
this.visiblePages.map(p => this.pageContainerCache[p.index].$container).forEach($c => $c.addClass('BRpage-exiting'));
|
731
|
+
nextPageContainers.forEach(c => c.$container.addClass('BRpage-entering'));
|
732
|
+
|
733
|
+
/** @type {KeyframeAnimationOptions} */
|
734
|
+
var animationStyle = {
|
735
|
+
duration: this.flipSpeed + this.activeFlip.pagesFlippingCount,
|
736
|
+
easing: 'ease-in',
|
737
|
+
fill: 'none'
|
738
|
+
};
|
739
|
+
var bookCenteringAnimation = this.$book.animate([{
|
740
|
+
transform: newTransform
|
741
|
+
}], animationStyle);
|
742
|
+
var edgeTranslationAnimation = this.$flippingEdges.animate([{
|
743
|
+
transform: "rotateY(0deg)"
|
744
|
+
}, {
|
745
|
+
transform: direction == 'left' ? "rotateY(-180deg)" : "rotateY(180deg)"
|
746
|
+
}], animationStyle);
|
747
|
+
var exitingPageAnimation = direction == 'left' ? this.querySelector('.BRpage-exiting[data-side=L]').animate([{
|
748
|
+
transform: "rotateY(0deg)"
|
749
|
+
}, {
|
750
|
+
transform: "rotateY(180deg)"
|
751
|
+
}], animationStyle) : this.querySelector('.BRpage-exiting[data-side=R]').animate([{
|
752
|
+
transform: "rotateY(0deg)"
|
753
|
+
}, {
|
754
|
+
transform: "rotateY(-180deg)"
|
755
|
+
}], animationStyle);
|
756
|
+
var enteringPageAnimation = direction == 'left' ? this.querySelector('.BRpage-entering[data-side=R]').animate([{
|
757
|
+
transform: "rotateY(-180deg)"
|
758
|
+
}, {
|
759
|
+
transform: "rotateY(0deg)"
|
760
|
+
}], animationStyle) : this.querySelector('.BRpage-entering[data-side=L]').animate([{
|
761
|
+
transform: "rotateY(180deg)"
|
762
|
+
}, {
|
763
|
+
transform: "rotateY(0deg)"
|
764
|
+
}], animationStyle);
|
765
|
+
bookCenteringAnimation.play();
|
766
|
+
edgeTranslationAnimation.play();
|
767
|
+
exitingPageAnimation.play();
|
768
|
+
enteringPageAnimation.play();
|
769
|
+
nextPageContainers.forEach(c => c.$container.addClass('BRpage-visible'));
|
770
|
+
yield Promise.race([promisifyEvent(bookCenteringAnimation, 'finish'), promisifyEvent(edgeTranslationAnimation, 'finish'), promisifyEvent(exitingPageAnimation, 'finish'), promisifyEvent(enteringPageAnimation, 'finish')]);
|
771
|
+
this.classList.remove("br-mode-2up--flipping-".concat(direction));
|
772
|
+
this.classList.remove("BRpageFlipping");
|
773
|
+
this.visiblePages.map(p => this.pageContainerCache[p.index].$container).forEach($c => $c.removeClass('BRpage-exiting BRpage-visible'));
|
774
|
+
nextPageContainers.forEach(c => c.$container.removeClass('BRpage-entering'));
|
775
|
+
this.activeFlip = null;
|
776
|
+
}
|
777
|
+
this.$book.style.transform = newTransform;
|
778
|
+
this.visiblePages = (progression == 'lr' ? [nextSpread.left, nextSpread.right] : [nextSpread.right, nextSpread.left]).filter(x => x);
|
779
|
+
});
|
780
|
+
function flipAnimation(_x2) {
|
781
|
+
return _flipAnimation.apply(this, arguments);
|
782
|
+
}
|
783
|
+
return flipAnimation;
|
784
|
+
}())
|
785
|
+
}, {
|
786
|
+
kind: "method",
|
787
|
+
key: "parseNextSpread",
|
788
|
+
value: function parseNextSpread(nextSpread) {
|
789
|
+
if (nextSpread == 'next') {
|
790
|
+
nextSpread = this.book.pageProgression == 'lr' ? 'right' : 'left';
|
791
|
+
} else if (nextSpread == 'prev') {
|
792
|
+
nextSpread = this.book.pageProgression == 'lr' ? 'left' : 'right';
|
793
|
+
}
|
794
|
+
var curSpread = (this.pageLeft || this.pageRight).spread;
|
795
|
+
if (nextSpread == 'left') {
|
796
|
+
var _curSpread$left2;
|
797
|
+
nextSpread = (_curSpread$left2 = curSpread.left) === null || _curSpread$left2 === void 0 || (_curSpread$left2 = _curSpread$left2.findLeft({
|
798
|
+
combineConsecutiveUnviewables: true
|
799
|
+
})) === null || _curSpread$left2 === void 0 ? void 0 : _curSpread$left2.spread;
|
800
|
+
} else if (nextSpread == 'right') {
|
801
|
+
var _curSpread$right;
|
802
|
+
nextSpread = (_curSpread$right = curSpread.right) === null || _curSpread$right === void 0 || (_curSpread$right = _curSpread$right.findRight({
|
803
|
+
combineConsecutiveUnviewables: true
|
804
|
+
})) === null || _curSpread$right === void 0 ? void 0 : _curSpread$right.spread;
|
805
|
+
}
|
806
|
+
if (typeof nextSpread == 'number') {
|
807
|
+
nextSpread = this.book.getPage(nextSpread).spread;
|
808
|
+
}
|
809
|
+
if (nextSpread instanceof PageModel) {
|
810
|
+
nextSpread = nextSpread.spread;
|
811
|
+
}
|
812
|
+
return nextSpread;
|
813
|
+
}
|
814
|
+
}, {
|
815
|
+
kind: "field",
|
816
|
+
key: "handlePageClick",
|
817
|
+
value() {
|
818
|
+
return ev => {
|
819
|
+
// right click
|
820
|
+
if (ev.which == 3 && this.br.protected) {
|
821
|
+
return false;
|
822
|
+
}
|
823
|
+
if (ev.which != 1) return;
|
824
|
+
var $page = $(ev.target).closest('.BRpagecontainer');
|
825
|
+
if (!$page.length) return;
|
826
|
+
if ($page.data('side') == 'L') {
|
827
|
+
this.flipAnimation('left');
|
828
|
+
} else if ($page.data('side') == 'R') {
|
829
|
+
this.flipAnimation('right');
|
830
|
+
}
|
831
|
+
};
|
832
|
+
}
|
833
|
+
}]
|
834
|
+
};
|
835
|
+
}, LitElement);
|
836
|
+
export var LeafEdges = _decorate(null, function (_initialize2, _LitElement2) {
|
837
|
+
class LeafEdges extends _LitElement2 {
|
838
|
+
constructor() {
|
839
|
+
super(...arguments);
|
840
|
+
_initialize2(this);
|
841
|
+
}
|
842
|
+
}
|
843
|
+
return {
|
844
|
+
F: LeafEdges,
|
845
|
+
d: [{
|
846
|
+
kind: "field",
|
847
|
+
decorators: [property({
|
848
|
+
type: Number
|
849
|
+
})],
|
850
|
+
key: "leftIndex",
|
851
|
+
value() {
|
852
|
+
return 0;
|
853
|
+
}
|
854
|
+
}, {
|
855
|
+
kind: "field",
|
856
|
+
decorators: [property({
|
857
|
+
type: Number
|
858
|
+
})],
|
859
|
+
key: "rightIndex",
|
860
|
+
value() {
|
861
|
+
return 0;
|
862
|
+
}
|
863
|
+
}, {
|
864
|
+
kind: "field",
|
865
|
+
decorators: [property({
|
866
|
+
type: String
|
867
|
+
})],
|
868
|
+
key: "side",
|
869
|
+
value() {
|
870
|
+
return 'left';
|
871
|
+
}
|
872
|
+
}, {
|
873
|
+
kind: "field",
|
874
|
+
decorators: [property({
|
875
|
+
attribute: false
|
876
|
+
})],
|
877
|
+
key: "book",
|
878
|
+
value() {
|
879
|
+
return null;
|
880
|
+
}
|
881
|
+
}, {
|
882
|
+
kind: "field",
|
883
|
+
decorators: [property({
|
884
|
+
attribute: false,
|
885
|
+
type: Function
|
886
|
+
})],
|
887
|
+
key: "pageClickHandler",
|
888
|
+
value() {
|
889
|
+
return null;
|
890
|
+
}
|
891
|
+
}, {
|
892
|
+
kind: "field",
|
893
|
+
decorators: [query('.br-leaf-edges__bar')],
|
894
|
+
key: "$hoverBar",
|
895
|
+
value: void 0
|
896
|
+
}, {
|
897
|
+
kind: "field",
|
898
|
+
decorators: [query('.br-leaf-edges__label')],
|
899
|
+
key: "$hoverLabel",
|
900
|
+
value: void 0
|
901
|
+
}, {
|
902
|
+
kind: "get",
|
903
|
+
key: "pageWidthPercent",
|
904
|
+
value: /** @type {'left' | 'right'} */
|
905
|
+
|
906
|
+
/** @type {BookModel} */
|
907
|
+
|
908
|
+
/** @type {(index: PageIndex) => void} */
|
909
|
+
|
910
|
+
function value() {
|
911
|
+
return 100 * 1 / (this.rightIndex - this.leftIndex + 1);
|
912
|
+
}
|
913
|
+
}, {
|
914
|
+
kind: "method",
|
915
|
+
key: "render",
|
916
|
+
value: function render() {
|
917
|
+
return html(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n <div\n class=\"br-leaf-edges__bar\"\n style=\"", "\"\n ></div>\n <div class=\"br-leaf-edges__label\">Page</div>"])), styleMap({
|
918
|
+
width: "".concat(this.pageWidthPercent, "%")
|
919
|
+
}));
|
920
|
+
}
|
921
|
+
}, {
|
922
|
+
kind: "method",
|
923
|
+
key: "connectedCallback",
|
924
|
+
value: function connectedCallback() {
|
925
|
+
_superPropGet(LeafEdges, "connectedCallback", this, 3)([]);
|
926
|
+
this.addEventListener('mouseenter', this.onMouseEnter);
|
927
|
+
this.addEventListener('mouseleave', this.onMouseLeave);
|
928
|
+
this.addEventListener('click', this.onClick);
|
929
|
+
}
|
930
|
+
}, {
|
931
|
+
kind: "method",
|
932
|
+
key: "disconnectedCallback",
|
933
|
+
value: function disconnectedCallback() {
|
934
|
+
_superPropGet(LeafEdges, "disconnectedCallback", this, 3)([]);
|
935
|
+
this.addEventListener('mouseenter', this.onMouseEnter);
|
936
|
+
this.removeEventListener('mousemove', this.onMouseMove);
|
937
|
+
this.removeEventListener('mouseleave', this.onMouseLeave);
|
938
|
+
}
|
939
|
+
|
940
|
+
/** @override */
|
941
|
+
}, {
|
942
|
+
kind: "method",
|
943
|
+
key: "createRenderRoot",
|
944
|
+
value: function createRenderRoot() {
|
945
|
+
// Disable shadow DOM; that would require a huge rejiggering of CSS
|
946
|
+
return this;
|
947
|
+
}
|
948
|
+
|
949
|
+
/**
|
950
|
+
* @param {MouseEvent} e
|
951
|
+
*/
|
952
|
+
}, {
|
953
|
+
kind: "field",
|
954
|
+
key: "onMouseEnter",
|
955
|
+
value() {
|
956
|
+
return e => {
|
957
|
+
this.addEventListener('mousemove', this.onMouseMove);
|
958
|
+
this.$hoverBar.style.display = 'block';
|
959
|
+
this.$hoverLabel.style.display = 'block';
|
960
|
+
};
|
961
|
+
}
|
962
|
+
}, {
|
963
|
+
kind: "field",
|
964
|
+
key: "onMouseMove",
|
965
|
+
value() {
|
966
|
+
return e => {
|
967
|
+
this.$hoverBar.style.left = "".concat(e.offsetX, "px");
|
968
|
+
if (this.side == 'right') {
|
969
|
+
this.$hoverLabel.style.left = "".concat(e.offsetX, "px");
|
970
|
+
} else {
|
971
|
+
this.$hoverLabel.style.right = "".concat(this.offsetWidth - e.offsetX, "px");
|
972
|
+
}
|
973
|
+
this.$hoverLabel.style.top = "".concat(e.offsetY, "px");
|
974
|
+
var index = this.mouseEventToPageIndex(e);
|
975
|
+
this.$hoverLabel.textContent = this.book.getPageName(index);
|
976
|
+
};
|
977
|
+
}
|
978
|
+
}, {
|
979
|
+
kind: "field",
|
980
|
+
key: "onMouseLeave",
|
981
|
+
value() {
|
982
|
+
return e => {
|
983
|
+
this.removeEventListener('mousemove', this.onMouseMove);
|
984
|
+
this.$hoverBar.style.display = 'none';
|
985
|
+
this.$hoverLabel.style.display = 'none';
|
986
|
+
};
|
987
|
+
}
|
988
|
+
}, {
|
989
|
+
kind: "field",
|
990
|
+
key: "onClick",
|
991
|
+
value() {
|
992
|
+
return e => {
|
993
|
+
this.pageClickHandler(this.mouseEventToPageIndex(e));
|
994
|
+
};
|
995
|
+
}
|
996
|
+
}, {
|
997
|
+
kind: "method",
|
998
|
+
key: "mouseEventToPageIndex",
|
999
|
+
value:
|
1000
|
+
/**
|
1001
|
+
* @param {MouseEvent} e
|
1002
|
+
*/
|
1003
|
+
/**
|
1004
|
+
* @param {MouseEvent} e
|
1005
|
+
*/
|
1006
|
+
/**
|
1007
|
+
* @param {MouseEvent} e
|
1008
|
+
*/
|
1009
|
+
/**
|
1010
|
+
* @param {MouseEvent} e
|
1011
|
+
* @returns {PageIndex}
|
1012
|
+
*/
|
1013
|
+
function mouseEventToPageIndex(e) {
|
1014
|
+
return Math.floor(this.leftIndex + e.offsetX / this.offsetWidth * (this.rightIndex - this.leftIndex + 1));
|
1015
|
+
}
|
1016
|
+
}]
|
1017
|
+
};
|
1018
|
+
}, LitElement);
|
1019
|
+
customElements.define('br-mode-2up', Mode2UpLit);
|
1020
|
+
customElements.define('br-leaf-edges', LeafEdges);
|