Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4840

in blazor app using javascript setScrollPos and getScrollPos to maintain scroll on list page

$
0
0

In my Blazor app, I'm using the following JavaScript to maintain scrolling on my list page after returning from details page. The user experience is not the greatest, it starts at top of the page then jumps to stored scroll position.

Is there a way to make that a better user experience? For example don't show the screen until it's back at the scroll position.

<script>    window.resetScroll = () => {        window.scrollTo(0, 0);    };    window.storeScrollPosition = () => {        sessionStorage.setItem('scrollPosition', window.scrollY);    };    window.restoreScrollPosition = () => {        const scrollPosition = sessionStorage.getItem('scrollPosition');        if (scrollPosition) {            window.scrollTo(0, parseInt(scrollPosition));            sessionStorage.removeItem('scrollPosition');        }    };</script>

Viewing all articles
Browse latest Browse all 4840

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>