@d-i-t-a/reader 2.0.0-beta.16 → 2.0.0-beta.17

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/dist/esm/index.js CHANGED
@@ -55643,6 +55643,14 @@ var IFrameNavigator = class extends import_events.default {
55643
55643
  this.nextChapterBottomAnchorElement.style.display = "none";
55644
55644
  if (this.previousChapterTopAnchorElement)
55645
55645
  this.previousChapterTopAnchorElement.style.display = "none";
55646
+ if (this.keyboardEventHandler) {
55647
+ this.keyboardEventHandler.onBackwardSwipe = this.handlePreviousChapterClick.bind(this);
55648
+ this.keyboardEventHandler.onForwardSwipe = this.handleNextChapterClick.bind(this);
55649
+ }
55650
+ if (this.touchEventHandler) {
55651
+ this.touchEventHandler.onBackwardSwipe = this.handlePreviousPageClick.bind(this);
55652
+ this.touchEventHandler.onForwardSwipe = this.handleNextPageClick.bind(this);
55653
+ }
55646
55654
  } else {
55647
55655
  this.settings.isPaginated().then((paginated) => {
55648
55656
  if (paginated) {
@@ -59707,6 +59715,7 @@ init_polyfills();
59707
59715
  var DEFAULT_BACKGROUND_COLOR_OPACITY2 = 0.5;
59708
59716
  var LineFocusModule = class {
59709
59717
  constructor(delegate, properties, highlighter, api) {
59718
+ this.hasEventListener = false;
59710
59719
  this.lines = [];
59711
59720
  this.index = 0;
59712
59721
  this.isActive = false;
@@ -59746,6 +59755,32 @@ var LineFocusModule = class {
59746
59755
  }
59747
59756
  }
59748
59757
  }
59758
+ keydown(event) {
59759
+ if (event instanceof KeyboardEvent) {
59760
+ const key = event.key;
59761
+ switch (key) {
59762
+ case "ArrowUp":
59763
+ event.stopPropagation();
59764
+ break;
59765
+ case "ArrowDown":
59766
+ event.stopPropagation();
59767
+ break;
59768
+ }
59769
+ }
59770
+ }
59771
+ keyup(event) {
59772
+ if (event instanceof KeyboardEvent) {
59773
+ const key = event.key;
59774
+ switch (key) {
59775
+ case "ArrowUp":
59776
+ this.lineUp();
59777
+ break;
59778
+ case "ArrowDown":
59779
+ this.lineDown();
59780
+ break;
59781
+ }
59782
+ }
59783
+ }
59749
59784
  handleResize() {
59750
59785
  if (this.isActive) {
59751
59786
  this.lineFocus();
@@ -59755,9 +59790,23 @@ var LineFocusModule = class {
59755
59790
  this.isActive = true;
59756
59791
  await this.delegate.settings.scroll(true);
59757
59792
  this.lineFocus();
59793
+ if (!this.hasEventListener) {
59794
+ this.hasEventListener = true;
59795
+ addEventListenerOptional(document, "keydown", this.keydown.bind(this));
59796
+ addEventListenerOptional(document, "keyup", this.keyup.bind(this));
59797
+ addEventListenerOptional(this.delegate.iframes[0].contentDocument, "keydown", this.keydown.bind(this));
59798
+ addEventListenerOptional(this.delegate.iframes[0].contentDocument, "keyup", this.keyup.bind(this));
59799
+ }
59758
59800
  }
59759
59801
  disableLineFocus(resetHeight = true) {
59760
59802
  this.isActive = false;
59803
+ if (this.hasEventListener) {
59804
+ this.hasEventListener = false;
59805
+ removeEventListenerOptional(document, "keydown", this.keydown.bind(this));
59806
+ removeEventListenerOptional(document, "keyup", this.keyup.bind(this));
59807
+ removeEventListenerOptional(this.delegate.iframes[0].contentDocument, "keydown", this.keydown.bind(this));
59808
+ removeEventListenerOptional(this.delegate.iframes[0].contentDocument, "keyup", this.keyup.bind(this));
59809
+ }
59761
59810
  const wrapper = findRequiredElement(document, "#iframe-wrapper");
59762
59811
  if (this.wrapperHeight) {
59763
59812
  wrapper.style.height = this.wrapperHeight;
@@ -59998,7 +60047,6 @@ var LineFocusModule = class {
59998
60047
  if (this.lineFocusBottomBlinder)
59999
60048
  this.lineFocusBottomBlinder.style.height = blindersHeight + "px";
60000
60049
  }
60001
- current.focus();
60002
60050
  current.scrollIntoView({
60003
60051
  block: "center",
60004
60052
  behavior: "smooth"
@@ -60022,7 +60070,6 @@ var LineFocusModule = class {
60022
60070
  if (this.lineFocusBottomBlinder)
60023
60071
  this.lineFocusBottomBlinder.style.height = blindersHeight + "px";
60024
60072
  }
60025
- current.focus();
60026
60073
  current.scrollIntoView({
60027
60074
  block: "center",
60028
60075
  behavior: "smooth"
@@ -60047,7 +60094,6 @@ var LineFocusModule = class {
60047
60094
  if (this.lineFocusBottomBlinder)
60048
60095
  this.lineFocusBottomBlinder.style.height = blindersHeight + "px";
60049
60096
  }
60050
- current.focus();
60051
60097
  current.scrollIntoView({
60052
60098
  block: "center",
60053
60099
  behavior: "smooth"