@@ -22499,15 +22499,33 @@ class PlexMeetsHomeAssistant extends HTMLElement {
2249922499 this.searchInputElem.style.display = 'none';
2250022500 }
2250122501 if (this.card) {
22502- const marginRight = 10; // needs to be equal to .container margin right
22503- const areaSize = this.card.offsetWidth - parseInt(this.card.style.paddingRight, 10) - parseInt(this.card.style.paddingLeft, 10);
22502+ // Todo: figure why 10.3 works
22503+ const marginRight = 10.3; // needs to be equal to .container margin right
22504+ const getAreaSize = () => {
22505+ if (this.card) {
22506+ return (this.card.getBoundingClientRect().width -
22507+ parseInt(this.card.style.paddingRight, 10) -
22508+ parseInt(this.card.style.paddingLeft, 10));
22509+ }
22510+ return 0;
22511+ };
22512+ const areaSize = getAreaSize();
2250422513 const postersInRow = Math.floor(areaSize / this.minWidth);
2250522514 if (areaSize > 0) {
2250622515 CSS_STYLE.width = areaSize / postersInRow - marginRight;
2250722516 CSS_STYLE.height = CSS_STYLE.width * CSS_STYLE.ratio;
2250822517 const episodesInRow = Math.floor(areaSize / this.minEpisodeWidth);
2250922518 CSS_STYLE.episodeWidth = Math.floor(areaSize / episodesInRow - marginRight);
2251022519 CSS_STYLE.episodeHeight = Math.round(CSS_STYLE.episodeWidth * CSS_STYLE.episodeRatio);
22520+ // hack to make sure cards width is always calculated properly, todo solve better in the future
22521+ setTimeout(() => {
22522+ if (this.card) {
22523+ const newAreaSize = getAreaSize();
22524+ if (newAreaSize !== areaSize) {
22525+ this.renderPage();
22526+ }
22527+ }
22528+ }, 1);
2251122529 }
2251222530 else if (this.renderPageRetries < 10) {
2251322531 // sometimes it loop forever, todo: properly fix!
@@ -23656,6 +23674,7 @@ class PlexMeetsHomeAssistant extends HTMLElement {
2365623674 }
2365723675 const container = document.createElement('div');
2365823676 container.className = 'plexMeetsContainer';
23677+ // console.log(CSS_STYLE);
2365923678 container.style.width = `${CSS_STYLE.width}px`;
2366023679 if (this.displayTitleMain || this.displaySubtitleMain) {
2366123680 container.style.marginBottom = '10px';
0 commit comments