Fix: Movie element position on close when scrolled all the way to bottom

pull/16/head
Juraj Nyíri 3 years ago
parent a25a21f2fa
commit 3086fd3542

@ -19707,6 +19707,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.plexProtocol = 'http'; this.plexProtocol = 'http';
this.detailsShown = false;
this.columnsCount = 0; this.columnsCount = 0;
this.renderedItems = 0; this.renderedItems = 0;
this.maxRenderCount = false; this.maxRenderCount = false;
@ -19729,8 +19730,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.renderNewElementsIfNeeded = () => { this.renderNewElementsIfNeeded = () => {
const loadAdditionalRowsCount = 2; // todo: make this configurable const loadAdditionalRowsCount = 2; // todo: make this configurable
const height = getHeight(this.content); const height = getHeight(this.content);
if (this.detailElem && if (!this.detailsShown &&
(this.detailElem.style.visibility === 'hidden' || this.detailElem.style.visibility === '') &&
window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 && window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 &&
this.renderedItems > 0) { this.renderedItems > 0) {
this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2); this.maxRenderCount = this.renderedItems - 1 + this.columnsCount * (loadAdditionalRowsCount * 2);
@ -19995,6 +19995,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
}; };
this.minimizeAll = () => { this.minimizeAll = () => {
this.detailsShown = false;
if (this.activeMovieElem) { if (this.activeMovieElem) {
this.activeMovieElem.style.display = `block`; this.activeMovieElem.style.display = `block`;
} }
@ -20079,9 +20080,13 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.detailElem.style.zIndex = '0'; this.detailElem.style.zIndex = '0';
this.detailElem.style.visibility = 'hidden'; this.detailElem.style.visibility = 'hidden';
} }
clearTimeout(this.renderNewElementsIfNeededTimeout);
this.renderNewElementsIfNeededTimeout = setTimeout(() => {
this.renderNewElementsIfNeeded(); this.renderNewElementsIfNeeded();
}, 1000);
}; };
this.showDetails = async (data) => { this.showDetails = async (data) => {
this.detailsShown = true;
const top = this.getTop(); const top = this.getTop();
if (this.detailElem) { if (this.detailElem) {
this.detailElem.style.transition = '0s'; this.detailElem.style.transition = '0s';
@ -20361,7 +20366,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} }
else { else {
const top = this.getTop(); const top = this.getTop();
this.minimizeAll();
this.showDetails(this.activeMovieElemData); this.showDetails(this.activeMovieElemData);
this.showBackground(); this.showBackground();
movieElemLocal.style.width = `${CSS_STYLE.expandedWidth}px`; movieElemLocal.style.width = `${CSS_STYLE.expandedWidth}px`;

@ -11,6 +11,10 @@ import style from './modules/style';
class PlexMeetsHomeAssistant extends HTMLElement { class PlexMeetsHomeAssistant extends HTMLElement {
plexProtocol: 'http' | 'https' = 'http'; plexProtocol: 'http' | 'https' = 'http';
detailsShown = false;
renderNewElementsIfNeededTimeout: any;
columnsCount = 0; columnsCount = 0;
renderedItems = 0; renderedItems = 0;
@ -105,8 +109,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
const loadAdditionalRowsCount = 2; // todo: make this configurable const loadAdditionalRowsCount = 2; // todo: make this configurable
const height = getHeight(this.content); const height = getHeight(this.content);
if ( if (
this.detailElem && !this.detailsShown &&
(this.detailElem.style.visibility === 'hidden' || this.detailElem.style.visibility === '') &&
window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 && window.innerHeight + window.scrollY > height + getOffset(this.content).top - 300 &&
this.renderedItems > 0 this.renderedItems > 0
) { ) {
@ -401,6 +404,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
}; };
minimizeAll = (): void => { minimizeAll = (): void => {
this.detailsShown = false;
if (this.activeMovieElem) { if (this.activeMovieElem) {
this.activeMovieElem.style.display = `block`; this.activeMovieElem.style.display = `block`;
} }
@ -490,10 +494,14 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.detailElem.style.zIndex = '0'; this.detailElem.style.zIndex = '0';
this.detailElem.style.visibility = 'hidden'; this.detailElem.style.visibility = 'hidden';
} }
clearTimeout(this.renderNewElementsIfNeededTimeout);
this.renderNewElementsIfNeededTimeout = setTimeout(() => {
this.renderNewElementsIfNeeded(); this.renderNewElementsIfNeeded();
}, 1000);
}; };
showDetails = async (data: any): Promise<void> => { showDetails = async (data: any): Promise<void> => {
this.detailsShown = true;
const top = this.getTop(); const top = this.getTop();
if (this.detailElem) { if (this.detailElem) {
this.detailElem.style.transition = '0s'; this.detailElem.style.transition = '0s';
@ -828,7 +836,6 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this.hideBackground(); this.hideBackground();
} else { } else {
const top = this.getTop(); const top = this.getTop();
this.minimizeAll();
this.showDetails(this.activeMovieElemData); this.showDetails(this.activeMovieElemData);
this.showBackground(); this.showBackground();
movieElemLocal.style.width = `${CSS_STYLE.expandedWidth}px`; movieElemLocal.style.width = `${CSS_STYLE.expandedWidth}px`;

Loading…
Cancel
Save