`; container.insertAdjacentHTML('beforeend', adElement); } }); // Son sayfaya ulaştığında URL'yi temizle if (!moreImagesAvailable) { clearPageFromURL(); } } isLoading = false; if (callback) callback(); }) .catch(error => { console.error('Error loading images:', error); isLoading = false; }); } // Scroll to image number from URL function scrollToImageNumber(imageNum) { const targetElement = document.getElementById(`page-${imageNum}`); if (targetElement) { targetElement.scrollIntoView({ behavior: "smooth", block: "start" }); window.scrollBy(0, -stickyMenuHeight); } } // Update URL based on scroll position function updateURLBasedOnScroll() { let nearestImageNum = null; let nearestDistance = Number.MAX_VALUE; const images = document.querySelectorAll('.image-container'); for (const img of images) { const rect = img.getBoundingClientRect(); const distance = Math.abs(rect.top - window.innerHeight / 2); if (distance < nearestDistance) { nearestDistance = distance; nearestImageNum = img.id.split('-')[1]; } } if (nearestImageNum !== null && moreImagesAvailable) { const currentUrl = window.location.href; const baseUrl = currentUrl.split('?')[0]; const newUrl = `${baseUrl}?page=${nearestImageNum}`; window.history.replaceState(null, null, newUrl); } } // URL'deki ?page= parametresini temizle function clearPageFromURL() { const currentUrl = window.location.href; const cleanUrl = currentUrl.split('?')[0]; // Sadece ?'dan önceki kısmı al window.history.replaceState(null, null, cleanUrl); } });