function loadScript(src) { return new Promise((resolve, reject) => { const script = document.createElement('script'); script.src = src; script.onload = resolve; script.onerror = reject; document.body.appendChild(script); }); } //loadScript('https://cdnjs.cloudflare.com/ajax/libs/photoswipe/5.4.4/umd/photoswipe.umd.min.js'); //loadScript('https://cdnjs.cloudflare.com/ajax/libs/photoswipe/5.4.4/umd/photoswipe-lightbox.umd.min.js'); function scrollToCursor(container, event) { const rect = container.getBoundingClientRect(); console.log('scrollToCursor',container); const cursorY = event.clientY; // Scroll down if cursor is below visible area if (cursorY > rect.bottom) { container.scrollTop += cursorY - rect.bottom; } // Scroll up if cursor is above visible area else if (cursorY < rect.top) { container.scrollTop -= rect.top - cursorY; } } document.addEventListener('click', function (e) { const btn = e.target.closest('.showDetail'); if (!btn) return; const wrapper = btn.closest('.inzeraty'); wrapper.classList.toggle('is-open'); const description = wrapper.querySelector('.bazarDescription'); description.classList.toggle('is-open'); btn.querySelector('small').textContent = description.classList.contains('is-open') ? 'zobraziť menej' : 'zobraziť viac'; //scrollToCursor(wrapper); if (wrapper.classList.contains('is-open')) { } else { console.log('scroll'); // wrapper.scrollIntoView({ // behavior: 'smooth', // block: 'start' // }); const offset = 40; // px above element const rect = wrapper.getBoundingClientRect(); window.scrollTo({ top: window.scrollY + rect.top - offset, behavior: 'smooth' }); } }); function initListingGalleries(scope = document) { scope.querySelectorAll('.inzeraty').forEach(listing => { // Prevent double init if (listing.dataset.pswpInitialized) return; console.log('aa'); const lightbox = new PhotoSwipeLightbox({ gallery: listing, children: 'a.img', // only images section pswpModule: PhotoSwipe }); lightbox.init(); // mark as initialized listing.dataset.pswpInitialized = 'true'; }); } var Zoznam = document.getElementById("ZOZNAM_VYSTAVOVATELOV"); Zoznam.innerHTML = '