export class ScrollPageManager {
    constructor() {
        this.key = "scrollpos";
        this.debounceTimeout = null;
        this.initialize();
    }
    initialize() {
        window.addEventListener("load", () => this.loadScrollPosition());
        window.addEventListener("scroll", () => this.debounceSaveScroll());
        window.addEventListener("beforeunload", () => this.saveScrollPosition());
    }
    loadScrollPosition() {
        const scrollpos = sessionStorage.getItem(this.key);
        if (scrollpos) {
            window.scrollTo(0, parseInt(scrollpos, 10));
            sessionStorage.removeItem(this.key);
        }
    }
    saveScrollPosition() {
        sessionStorage.setItem(this.key, window.scrollY.toString());
    }
    debounceSaveScroll() {
        if (this.debounceTimeout !== null) {
            clearTimeout(this.debounceTimeout);
        }
        this.debounceTimeout = window.setTimeout(() => {
            this.saveScrollPosition();
        }, 200);
    }
}
//# sourceMappingURL=ScrollPageManager.js.map