mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-02-06 12:18:25 -06:00
Keep aside scroll between reloads
This commit is contained in:
@@ -2,8 +2,10 @@ import { initNotyf } from './init-notyf.js'
|
||||
import { initHTMX } from './init-htmx.js'
|
||||
import { initAlpineComponents } from './init-alpine-components.js'
|
||||
import { initCopyFunction } from './init-copy-function.js'
|
||||
import { initDashboardAsideScroll } from './dashboard-aside-scroll.js'
|
||||
|
||||
initNotyf()
|
||||
initHTMX()
|
||||
initAlpineComponents()
|
||||
initCopyFunction()
|
||||
initDashboardAsideScroll()
|
||||
|
||||
16
internal/view/static/js/dashboard-aside-scroll.js
Normal file
16
internal/view/static/js/dashboard-aside-scroll.js
Normal file
@@ -0,0 +1,16 @@
|
||||
export function initDashboardAsideScroll () {
|
||||
const el = document.getElementById('dashboard-aside')
|
||||
const key = 'dashboard-aside-scroll-position'
|
||||
|
||||
window.addEventListener('beforeunload', function () {
|
||||
const scrollPosition = el.scrollTop
|
||||
localStorage.setItem(key, scrollPosition)
|
||||
})
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const scrollPosition = localStorage.getItem(key)
|
||||
if (scrollPosition) {
|
||||
el.scrollTop = parseInt(scrollPosition, 10)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
func dashboardAside() gomponents.Node {
|
||||
return html.Aside(
|
||||
html.ID("dashboard-aside"),
|
||||
components.Classes{
|
||||
"flex-none h-[100dvh] bg-base-300 shadow-sm p-4": true,
|
||||
"overflow-y-auto overflow-x-hidden": true,
|
||||
|
||||
Reference in New Issue
Block a user