Thursday, 5 May 2022

Back to previous page same scroll position with lazy load images on page using jquery

Working on scroll position when user goes back to the previous page then same scroll position of the product will show. I have tried like this

$('.test').on('click', function(e){

        stateData = {
            path: window.location.href,
            scrollTop: $(window).scrollTop()
        };
        const url = new URL(window.location);
        window.history.replaceState(stateData, '', url);
        stateData = {
            path: window.location.href,
            scrollTop: 0
        };
        window.history.pushState(stateData, '', url);
        e.preventDefault();;
    });

But here I'm not getting the exact position due to lazy load images to scroll moving at the bottom of the page. Can anyone suggest to me how to handle it?



from Back to previous page same scroll position with lazy load images on page using jquery

No comments:

Post a Comment