1/** 2 * Dynamiczny clamp leadów kart artykuÅów. 3 * 4 * Cel: wielokropek ââ¦" w leadzie ma siÄ pojawiaÄ DOKÅADNIE wtedy, gdy lead nie 5 * mieÅci siÄ w dostÄpnej (zmiennej) przestrzeni karty â nie po sztywnych N wierszach. 6 * 7 * Karta ma staÅÄ wysokoÅÄ, a `.card__lead` ma `flex:1`, wiÄc jego wysokoÅÄ renderowana 8 * (`clientHeight`) = miejsce, które realnie zostaÅo po tytule (1â4 wiersze) i miniaturze. 9 * Liczymy ile peÅnych wierszy siÄ tam mieÅci i ustawiamy `-webkit-line-clamp` na tÄ liczbÄ. 10 * 11 * Fallback bez JS: CSS `.card__lead { -webkit-line-clamp: 3 }` (zachowanie dotychczasowe). 12 * Progresywne ulepszenie â nie psuje renderu, gdy skrypt siÄ nie wykona. 13 */ 14(() => { 15 if (typeof document === 'undefined') return; 16 // Brak wsparcia line-clamp â zostawiamy CSS-owy fallback. 17 if (!('webkitLineClamp' in document.documentElement.style)) return; 18 19 const SELECTOR = '.card__lead, .card--hero-style__lead'; 20 21 const clampOne = (lead) => { 22 const cs = getComputedStyle(lead); 23 const lineHeight = parseFloat(cs.lineHeight); 24 if (!lineHeight || Number.isNaN(lineHeight)) return; 25 26 // clientHeight = wysokoÅÄ przydzielona przez flex (= dostÄpne miejsce w karcie). 27 const avail = lead.clientHeight; 28 if (avail <= 0) return; 29 30 const lines = Math.max(1, Math.floor(avail / lineHeight)); 31 lead.style.webkitLineClamp = String(lines); 32 }; 33 34 const clampAll = () => { 35 document.querySelectorAll(SELECTOR).forEach(clampOne); 36 }; 37 38 const onReady = () => requestAnimationFrame(clampAll); 39 40 if (document.readyState === 'loading') { 41 document.addEventListener('DOMContentLoaded', onReady, { once: true }); 42 } else { 43 onReady(); 44 } 45 46 let resizeTimer = null; 47 window.addEventListener('resize', () => { 48 if (resizeTimer) clearTimeout(resizeTimer); 49 resizeTimer = setTimeout(() => requestAnimationFrame(clampAll), 150); 50 }); 51})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.