|
|
@ -610,15 +610,15 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
this.renderedItems < this.data[this.config.libraryName].length &&
|
|
|
|
this.renderedItems < this.data[this.config.libraryName].length &&
|
|
|
|
renderMore
|
|
|
|
renderMore
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let count = 0;
|
|
|
|
|
|
|
|
let maxRenderedItems = this.data[this.config.libraryName].length;
|
|
|
|
let maxRenderedItems = this.data[this.config.libraryName].length;
|
|
|
|
let itemsPerRow = this.data[this.config.libraryName].length;
|
|
|
|
let itemsPerRow = this.data[this.config.libraryName].length;
|
|
|
|
if (this.maxCount) {
|
|
|
|
if (this.maxCount) {
|
|
|
|
maxRenderedItems = this.maxCount;
|
|
|
|
maxRenderedItems = this.maxCount;
|
|
|
|
itemsPerRow = maxRenderedItems;
|
|
|
|
itemsPerRow = maxRenderedItems;
|
|
|
|
if (this.maxRows) {
|
|
|
|
if (this.maxRows) {
|
|
|
|
itemsPerRow = Math.round(maxRenderedItems / this.maxRows);
|
|
|
|
itemsPerRow = Math.ceil(maxRenderedItems / this.maxRows);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(itemsPerRow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
const searchValues = _.split(this.searchValue, ' ');
|
|
|
|
const searchValues = _.split(this.searchValue, ' ');
|
|
|
@ -630,11 +630,11 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
this.columnsCount = 0;
|
|
|
|
this.columnsCount = 0;
|
|
|
|
const hasEpisodesResult = hasEpisodes(this.data[this.config.libraryName]);
|
|
|
|
const hasEpisodesResult = hasEpisodes(this.data[this.config.libraryName]);
|
|
|
|
_.forEach(this.data[this.config.libraryName], (movieData: Record<string, any>) => {
|
|
|
|
_.forEach(this.data[this.config.libraryName], (movieData: Record<string, any>) => {
|
|
|
|
if (renderMore) {
|
|
|
|
|
|
|
|
renderMore =
|
|
|
|
renderMore =
|
|
|
|
(!this.maxCount || this.renderedItems < this.maxCount) &&
|
|
|
|
(!this.maxCount || this.renderedItems < this.maxCount) &&
|
|
|
|
(!this.maxRenderCount || this.renderedItems < this.maxRenderCount) &&
|
|
|
|
(!this.maxRenderCount || this.renderedItems < this.maxRenderCount) &&
|
|
|
|
(!this.maxRows || this.renderedRows <= this.maxRows);
|
|
|
|
(!this.maxRows || this.renderedRows <= this.maxRows);
|
|
|
|
|
|
|
|
if (renderMore) {
|
|
|
|
const movieElem = this.getMovieElement(movieData, hasEpisodesResult);
|
|
|
|
const movieElem = this.getMovieElement(movieData, hasEpisodesResult);
|
|
|
|
let shouldRender = false;
|
|
|
|
let shouldRender = false;
|
|
|
|
if (this.looseSearch) {
|
|
|
|
if (this.looseSearch) {
|
|
|
@ -663,11 +663,14 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
shouldRender = true;
|
|
|
|
shouldRender = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (shouldRender) {
|
|
|
|
if (shouldRender) {
|
|
|
|
count += 1;
|
|
|
|
|
|
|
|
if (count > this.renderedItems) {
|
|
|
|
|
|
|
|
this.contentContainer.appendChild(movieElem);
|
|
|
|
this.contentContainer.appendChild(movieElem);
|
|
|
|
if (this.useHorizontalScroll) {
|
|
|
|
if (this.useHorizontalScroll) {
|
|
|
|
|
|
|
|
if (this.renderedItems > 0 && this.renderedItems % itemsPerRow === 0) {
|
|
|
|
|
|
|
|
this.renderedRows += 1;
|
|
|
|
|
|
|
|
movieElem.style.clear = 'both';
|
|
|
|
|
|
|
|
}
|
|
|
|
const marginRight = 10;
|
|
|
|
const marginRight = 10;
|
|
|
|
|
|
|
|
if (this.renderedRows === 1) {
|
|
|
|
if (_.isEmpty(this.contentContainer.style.width)) {
|
|
|
|
if (_.isEmpty(this.contentContainer.style.width)) {
|
|
|
|
this.contentContainer.style.width = `${parseFloat(movieElem.style.width) + marginRight}px`;
|
|
|
|
this.contentContainer.style.width = `${parseFloat(movieElem.style.width) + marginRight}px`;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -676,10 +679,10 @@ class PlexMeetsHomeAssistant extends HTMLElement {
|
|
|
|
marginRight}px`;
|
|
|
|
marginRight}px`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.renderedItems += 1;
|
|
|
|
this.renderedItems += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shouldRender && lastRowTop !== movieElem.getBoundingClientRect().top && !this.useHorizontalScroll) {
|
|
|
|
if (shouldRender && lastRowTop !== movieElem.getBoundingClientRect().top && !this.useHorizontalScroll) {
|
|
|
|
this.renderedRows += 1;
|
|
|
|
this.renderedRows += 1;
|
|
|
|
if (lastRowTop !== 0 && this.columnsCount === 0) {
|
|
|
|
if (lastRowTop !== 0 && this.columnsCount === 0) {
|
|
|
|