Skip to content

A self-hosted media server and file management system

auto scroll to top on page change

aminnausin725d498ea4aa
diff --git a/resources/js/router/index.js b/resources/js/router/index.js
index c0da0f7a..a006c309 100644
--- a/resources/js/router/index.js
+++ b/resources/js/router/index.js
@@ -131,4 +131,11 @@ router.beforeEach(async (to, from, next) => {
});
})
+router.afterEach((to) => { // Scroll to top on every spa page load
+ if(to?.name === 'home') return;
+
+ let root = document.getElementById('root');
+ root.scrollIntoView();
+});
+
export default router;
\ No newline at end of file