scroll to the correct position regardless of the position or height of the header

This commit is contained in:
Athou
2024-01-18 08:52:06 +01:00
parent 5f29838bd2
commit 99db85328b
3 changed files with 9 additions and 4 deletions

View File

@@ -89,10 +89,14 @@ export const Constants = {
mobileBreakpointName: "md",
headerHeight: 60,
entryMaxWidth: 650,
isTopVisible: (div: HTMLElement) => div.getBoundingClientRect().top >= Constants.layout.headerHeight,
isTopVisible: (div: HTMLElement) => {
const header = document.getElementById(Constants.dom.headerId)?.getBoundingClientRect()
return div.getBoundingClientRect().top >= (header?.bottom ?? 0)
},
isBottomVisible: (div: HTMLElement) => div.getBoundingClientRect().bottom <= window.innerHeight,
},
dom: {
headerId: "header",
entryId: (entry: Entry) => `entry-id-${entry.id}`,
entryContextMenuId: (entry: Entry) => entry.id,
},