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 () => {
window.addEventListener('scroll', () => {
if (this.detailsShown &&
this.activeMovieElem &&
this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10)) {
window.scroll({
top: getOffset(this.activeMovieElem).top - 80
});
if (this.detailsShown && this.activeMovieElem) {
if (this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10)) {
window.scroll({
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();
});

@ -149,15 +149,30 @@ class PlexMeetsHomeAssistant extends HTMLElement {
loadInitialData = async (): Promise<void> => {
window.addEventListener('scroll', () => {
if (
this.detailsShown &&
this.activeMovieElem &&
this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10)
) {
window.scroll({
top: getOffset(this.activeMovieElem as Element).top - 80
});
if (this.detailsShown && this.activeMovieElem) {
if (this.getTop() + 15 < parseInt(this.activeMovieElem.style.top, 10)) {
window.scroll({
top: getOffset(this.activeMovieElem as Element).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] 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();
});
window.addEventListener('resize', () => {

Loading…
Cancel
Save