Add: WIP stop scrolling bottom

pull/16/head
Juraj Nyíri 4 years ago
parent bdbaac382f
commit e80ae67128

@ -20015,12 +20015,28 @@ class PlexMeetsHomeAssistant extends HTMLElement {
}; };
this.loadInitialData = async () => { this.loadInitialData = async () => {
window.addEventListener('scroll', () => { window.addEventListener('scroll', () => {
if (this.detailsShown && if (this.detailsShown && this.activeMovieElem) {
this.activeMovieElem && if (this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10)) {
this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10)) { window.scroll({
window.scroll({ top: getOffset(this.activeMovieElem).top - 80
top: getOffset(this.activeMovieElem).top - 80 });
}); }
else {
// todo move final bottom value to class to safe performance
// todo: make it work with episodes and extras
const season = this.getElementsByClassName('seasons')[0];
const seasonContainers = this.getElementsByClassName('seasonContainer');
const lastSeasonContainer = seasonContainers[seasonContainers.length - 1];
const seasonContainersBottom = parseInt(lastSeasonContainer.style.top, 10) +
parseInt(season.style.top, 10) +
getHeight(lastSeasonContainer) +
60;
if (this.getTop() + window.innerHeight > seasonContainersBottom) {
window.scroll({
top: seasonContainersBottom - window.innerHeight
});
}
}
} }
this.renderNewElementsIfNeeded(); this.renderNewElementsIfNeeded();
}); });

@ -149,15 +149,30 @@ class PlexMeetsHomeAssistant extends HTMLElement {
loadInitialData = async (): Promise<void> => { loadInitialData = async (): Promise<void> => {
window.addEventListener('scroll', () => { window.addEventListener('scroll', () => {
if ( if (this.detailsShown && this.activeMovieElem) {
this.detailsShown && if (this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10)) {
this.activeMovieElem && window.scroll({
this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10) top: getOffset(this.activeMovieElem as Element).top - 80
) { });
window.scroll({ } else {
top: getOffset(this.activeMovieElem as Element).top - 80 // todo move final bottom value to class to safe performance
}); // todo: make it work with episodes and extras
const season = this.getElementsByClassName('seasons')[0] as HTMLElement;
const seasonContainers = this.getElementsByClassName('seasonContainer');
const lastSeasonContainer = seasonContainers[seasonContainers.length - 1] as HTMLElement;
const seasonContainersBottom =
parseInt(lastSeasonContainer.style.top, 10) +
parseInt(season.style.top, 10) +
getHeight(lastSeasonContainer) +
60;
if (this.getTop() + window.innerHeight > seasonContainersBottom) {
window.scroll({
top: seasonContainersBottom - window.innerHeight
});
}
}
} }
this.renderNewElementsIfNeeded(); this.renderNewElementsIfNeeded();
}); });
window.addEventListener('resize', () => { window.addEventListener('resize', () => {

Loading…
Cancel
Save