@netless/app-slide 0.1.1 → 0.1.2

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/main.es.js CHANGED
@@ -36750,6 +36750,8 @@ class SlideController {
36750
36750
  }
36751
36751
  };
36752
36752
  this.unfreeze = async () => {
36753
+ if (!this.visible)
36754
+ return;
36753
36755
  if (this.ready) {
36754
36756
  log("[Slide] unfreeze", this.context.appId);
36755
36757
  if (this.freezePromise) {
@@ -36762,6 +36764,18 @@ class SlideController {
36762
36764
  this._toFreeze = -1;
36763
36765
  }
36764
36766
  };
36767
+ this.onVisibilityChange = async () => {
36768
+ if (!(this.visible = document.visibilityState === "visible")) {
36769
+ this.savedIsFrozen = this.freezePromise ? this._toFreeze === 1 : this.isFrozen;
36770
+ log("[Slide] freeze because tab becomes invisible");
36771
+ this.freeze();
36772
+ } else {
36773
+ log("[Slide] unfreeze because tab becomes visible", { savedIsFrozen: this.savedIsFrozen });
36774
+ if (!this.savedIsFrozen) {
36775
+ this.unfreeze();
36776
+ }
36777
+ }
36778
+ };
36765
36779
  this.onPageChanged = onPageChanged;
36766
36780
  this.onTransitionStart = onTransitionStart;
36767
36781
  this.onTransitionEnd = onTransitionEnd;
@@ -36771,6 +36785,8 @@ class SlideController {
36771
36785
  this.player = this.room ? void 0 : context.getDisplayer();
36772
36786
  this.slide = this.createSlide(anchor);
36773
36787
  this.syncStateOnceFlag = !this.context.isAddApp;
36788
+ this.visible = document.visibilityState === "visible";
36789
+ this.savedIsFrozen = false;
36774
36790
  this.initialize();
36775
36791
  }
36776
36792
  jumpToPage(page) {
@@ -36820,6 +36836,10 @@ class SlideController {
36820
36836
  slide.on(Slide.SLIDE_EVENTS.stateChange, this.onStateChange);
36821
36837
  slide.on(Slide.SLIDE_EVENTS.syncDispatch, this.onSyncDispatch);
36822
36838
  slide.on(Slide.SLIDE_EVENTS.renderEnd, this.resolveReady);
36839
+ this.sideEffect.add(() => {
36840
+ document.addEventListener("visibilitychange", this.onVisibilityChange);
36841
+ return () => document.removeEventListener("visibilitychange", this.onVisibilityChange);
36842
+ });
36823
36843
  }
36824
36844
  syncStateOnce() {
36825
36845
  if (this.syncStateOnceFlag) {
@@ -38214,7 +38234,7 @@ class SlidePreviewer {
38214
38234
  return `${this.namespace}-${className}`;
38215
38235
  }
38216
38236
  }
38217
- const version = "0.1.1";
38237
+ const version = "0.1.2";
38218
38238
  const SlideApp = {
38219
38239
  kind: "Slide",
38220
38240
  setup(context) {