Refactors header and scroll management logic
Updates ScrollManager to dynamically sync header spacer height using ResizeObserver Removes explicit spacer animation from HeaderDrawerManager Simplifies header and scroll interaction by moving height synchronization logic to ScrollManager
This commit is contained in:
parent
899c600e44
commit
dee977d4df
3 changed files with 32 additions and 7 deletions
|
|
@ -1,13 +1,13 @@
|
||||||
export class HeaderDrawerManager {
|
export class HeaderDrawerManager {
|
||||||
private drawer!: HTMLElement;
|
private drawer!: HTMLElement;
|
||||||
private spacer!: HTMLElement;
|
|
||||||
private expanded = false;
|
private expanded = false;
|
||||||
private readonly expandedHeight = 24;
|
private readonly expandedHeight = 24;
|
||||||
private readonly duration = 200;
|
private readonly duration = 200;
|
||||||
|
|
||||||
init(container: HTMLElement): void {
|
init(container: HTMLElement): void {
|
||||||
this.drawer = container.querySelector('swp-header-drawer')!;
|
this.drawer = container.querySelector('swp-header-drawer')!;
|
||||||
this.spacer = container.querySelector('swp-header-spacer')!;
|
|
||||||
|
if (!this.drawer) console.error('HeaderDrawerManager: swp-header-drawer not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle(): void {
|
toggle(): void {
|
||||||
|
|
@ -37,8 +37,8 @@ export class HeaderDrawerManager {
|
||||||
fill: 'forwards'
|
fill: 'forwards'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Kun animér drawer - ScrollManager synkroniserer header-spacer via ResizeObserver
|
||||||
this.drawer.animate(keyframes, options);
|
this.drawer.animate(keyframes, options);
|
||||||
this.spacer.animate(keyframes, options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isExpanded(): boolean {
|
isExpanded(): boolean {
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,29 @@ export class ScrollManager {
|
||||||
private scrollableContent!: HTMLElement;
|
private scrollableContent!: HTMLElement;
|
||||||
private timeAxisContent!: HTMLElement;
|
private timeAxisContent!: HTMLElement;
|
||||||
private calendarHeader!: HTMLElement;
|
private calendarHeader!: HTMLElement;
|
||||||
|
private headerViewport!: HTMLElement;
|
||||||
|
private headerSpacer!: HTMLElement;
|
||||||
|
private resizeObserver!: ResizeObserver;
|
||||||
|
|
||||||
init(container: HTMLElement): void {
|
init(container: HTMLElement): void {
|
||||||
this.scrollableContent = container.querySelector('swp-scrollable-content')!;
|
this.scrollableContent = container.querySelector('swp-scrollable-content')!;
|
||||||
this.timeAxisContent = container.querySelector('swp-time-axis-content')!;
|
this.timeAxisContent = container.querySelector('swp-time-axis-content')!;
|
||||||
this.calendarHeader = container.querySelector('swp-calendar-header')!;
|
this.calendarHeader = container.querySelector('swp-calendar-header')!;
|
||||||
|
this.headerViewport = container.querySelector('swp-header-viewport')!;
|
||||||
|
this.headerSpacer = container.querySelector('swp-header-spacer')!;
|
||||||
|
|
||||||
this.scrollableContent.addEventListener('scroll', () => this.onScroll());
|
this.scrollableContent.addEventListener('scroll', () => this.onScroll());
|
||||||
|
|
||||||
|
// Synkroniser header-spacer højde med header-viewport
|
||||||
|
this.resizeObserver = new ResizeObserver(() => this.syncHeaderSpacerHeight());
|
||||||
|
this.resizeObserver.observe(this.headerViewport);
|
||||||
|
this.syncHeaderSpacerHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
private syncHeaderSpacerHeight(): void {
|
||||||
|
// Kopier den faktiske computed height direkte fra header-viewport
|
||||||
|
const computedHeight = getComputedStyle(this.headerViewport).height;
|
||||||
|
this.headerSpacer.style.height = computedHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private onScroll(): void {
|
private onScroll(): void {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
--day-column-min-width: 200px;
|
--day-column-min-width: 200px;
|
||||||
--day-start-hour: 6;
|
--day-start-hour: 6;
|
||||||
--day-end-hour: 18;
|
--day-end-hour: 18;
|
||||||
|
--header-height: 70px;
|
||||||
--color-border: #e0e0e0;
|
--color-border: #e0e0e0;
|
||||||
--color-surface: #fff;
|
--color-surface: #fff;
|
||||||
--color-text-secondary: #666;
|
--color-text-secondary: #666;
|
||||||
|
|
@ -81,12 +82,16 @@ swp-time-axis {
|
||||||
grid-column: 1;
|
grid-column: 1;
|
||||||
grid-row: 1 / 3;
|
grid-row: 1 / 3;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: subgrid;
|
grid-template-rows: auto 1fr;
|
||||||
border-right: 1px solid var(--color-border);
|
border-right: 1px solid var(--color-border);
|
||||||
background: var(--color-surface);
|
background: var(--color-surface);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swp-header-spacer {
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
swp-header-drawer {
|
swp-header-drawer {
|
||||||
display: block;
|
display: block;
|
||||||
height: 0;
|
height: 0;
|
||||||
|
|
@ -96,9 +101,9 @@ swp-header-drawer {
|
||||||
}
|
}
|
||||||
|
|
||||||
swp-time-axis-content {
|
swp-time-axis-content {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-auto-rows: var(--hour-height);
|
flex-direction: column;
|
||||||
overflow: hidden;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
swp-hour-marker {
|
swp-hour-marker {
|
||||||
|
|
@ -118,6 +123,10 @@ swp-hour-marker {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
background: var(--color-hour-line);
|
background: var(--color-hour-line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:first-child::after {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grid container */
|
/* Grid container */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue