I have the following code to save my data in current page state.
window.history.pushState({myData: data}, "RandomTitle", '#');
But now, I want to also save another value which is scrollTop. And if I do
window.history.pushState({scrollTop: scrollTop}, "RandomTitle", '#');
The code above will replace the history state with the new one and myData will be gone.
The question, Is there anyway I can add scrollTop while there's myData in my history state? Or I just have to set it initially like,
window.history.pushState({myData: data, scrollTop: 0}, "RandomTitle", '#');
// To change the scrollTop in history state
window.history.state.scrollTop = $(window).scrollTop();
I am thinking if there's a function like window.history.state.addObject or something.
 
     
    