Add scroll memory
This commit is contained in:
@ -5,4 +5,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// You can delete this file if you're not using it
|
// You can delete this file if you're not using it
|
||||||
export { default as wrapRootElement } from './src/docs/state/ReduxWrapper'
|
|
||||||
|
let locationScrollTops = [];
|
||||||
|
|
||||||
|
const onPreRouteUpdate = ({ location, prevLocation }) => {
|
||||||
|
try {
|
||||||
|
let scrollTop = document.querySelector('.content').scrollTop;
|
||||||
|
locationScrollTops[prevLocation.pathname] = scrollTop;
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onRouteUpdate = ({ location, prevLocation }) => {
|
||||||
|
console.log(locationScrollTops)
|
||||||
|
try {
|
||||||
|
if (locationScrollTops[location.pathname]) {
|
||||||
|
document.querySelector('.content').scrollTop = locationScrollTops[location.pathname];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export { default as wrapRootElement } from './src/docs/state/ReduxWrapper';
|
||||||
|
export { onPreRouteUpdate, onRouteUpdate };
|
||||||
|
|||||||
Reference in New Issue
Block a user