embeds: only show replay in embedded mode when visible, using IntersectionObserver to detect when off-screen
This commit is contained in:
+15
-3
@@ -63,6 +63,8 @@ class Coll extends LitElement
|
|||||||
|
|
||||||
this.showSidebar = localStorage.getItem(`pages:showSidebar`) === "1";
|
this.showSidebar = localStorage.getItem(`pages:showSidebar`) === "1";
|
||||||
this.splitter = null;
|
this.splitter = null;
|
||||||
|
|
||||||
|
this.isVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get properties() {
|
static get properties() {
|
||||||
@@ -89,7 +91,9 @@ class Coll extends LitElement
|
|||||||
menuActive: { type: Boolean },
|
menuActive: { type: Boolean },
|
||||||
|
|
||||||
embed: { type: String },
|
embed: { type: String },
|
||||||
editable: { type: Boolean }
|
editable: { type: Boolean },
|
||||||
|
|
||||||
|
isVisible: { type: Boolean }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +105,14 @@ class Coll extends LitElement
|
|||||||
this.addEventListener("fullscreenchange", (event) => {
|
this.addEventListener("fullscreenchange", (event) => {
|
||||||
this.isFullscreen = !!document.fullscreenElement;
|
this.isFullscreen = !!document.fullscreenElement;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.embed) {
|
||||||
|
this.observer = new IntersectionObserver((entries, observer) => {
|
||||||
|
this.isVisible = entries[0].isIntersecting;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.observer.observe(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updated(changedProperties) {
|
updated(changedProperties) {
|
||||||
@@ -548,7 +560,7 @@ class Coll extends LitElement
|
|||||||
${this.renderCollTabs(isSidebar)}
|
${this.renderCollTabs(isSidebar)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${isReplay ? html`
|
${isReplay && this.isVisible ? html`
|
||||||
<wr-coll-replay
|
<wr-coll-replay
|
||||||
role="main"
|
role="main"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
@@ -558,7 +570,7 @@ class Coll extends LitElement
|
|||||||
ts="${this.tabData.ts || ""}"
|
ts="${this.tabData.ts || ""}"
|
||||||
@coll-tab-nav="${this.onCollTabNav}" id="replay"
|
@coll-tab-nav="${this.onCollTabNav}" id="replay"
|
||||||
@replay-loading="${(e) => this.isLoading = e.detail.loading}"
|
@replay-loading="${(e) => this.isLoading = e.detail.loading}"
|
||||||
class="${isReplay ? '' : 'is-hidden'}">
|
>
|
||||||
</wr-coll-replay>
|
</wr-coll-replay>
|
||||||
` : ``}
|
` : ``}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user