Filtreler
Sırala:
50%
1.299,00 TL
649,50 TL
(function () {
// Tarayıcının otomatik scroll restorasyonunu kapat (biz yöneteceğiz)
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}
// Her sayfa için ayrı anahtar (path + query)
const KEY = 'scroll:' + location.pathname + location.search;
// Güvenli storage helper (bazı modlarda hata fırlayabilir)
const storage = {
get() {
try {
const v = sessionStorage.getItem(KEY);
return v ? parseInt(v, 10) : 0;
} catch { return 0; }
},
set(y) {
try { sessionStorage.setItem(KEY, String(Math.max(0, y|0))); } catch {}
}
};
// Scroll konumunu ara ara kaydet (çok sık yazmamak için küçük bir debounce)
let t = null;
const saveScroll = () => {
if (t) return;
t = setTimeout(() => { t = null; storage.set(window.scrollY); }, 150);
};
window.addEventListener('scroll', saveScroll, { passive: true });
// Sekme/sayfa kapanırken de son konumu yakala
window.addEventListener('pagehide', () => storage.set(window.scrollY));
window.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') storage.set(window.scrollY);
});
window.addEventListener('beforeunload', () => storage.set(window.scrollY));
// Geri yükleme: resimler/css yüklensin ki doğru yüksekliğe sarabilelim
const restore = () => {
// Eğer #hash varsa kullanıcı bilinçli bir yere gitmek istiyor, dokunmayalım
if (location.hash) return;
const y = storage.get();
if (y > 0) {
// layout otursun diye bir frame ve çok küçük bir gecikme verelim
requestAnimationFrame(() => {
setTimeout(() => window.scrollTo({ top: y, behavior: 'instant' in window ? 'instant' : 'auto' }), 0);
});
}
};
// Hem DOM hazır olduğunda hem tüm kaynaklar yüklendiğinde deneyelim
if (document.readyState === 'complete') {
restore();
} else {
window.addEventListener('load', restore);
document.addEventListener('DOMContentLoaded', () => setTimeout(restore, 0));
}
})();