Moves event positioning to renderer
Relocates event CSS positioning logic from the `SwpEventElement` to the `DateEventRenderer`. This improves separation of concerns, making the renderer responsible for event layout.
This commit is contained in:
parent
5fae433afb
commit
57bf122675
2 changed files with 11 additions and 12 deletions
|
|
@ -85,7 +85,6 @@ export class SwpEventElement extends BaseSwpEventElement {
|
||||||
if (!this.hasChildNodes()) {
|
if (!this.hasChildNodes()) {
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
this.applyPositioning();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -193,16 +192,6 @@ export class SwpEventElement extends BaseSwpEventElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply initial positioning based on start/end times
|
|
||||||
*/
|
|
||||||
private applyPositioning(): void {
|
|
||||||
const position = PositionUtils.calculateEventPosition(this.start, this.end);
|
|
||||||
this.style.top = `${position.top + 1}px`;
|
|
||||||
this.style.height = `${position.height - 3}px`;
|
|
||||||
this.style.left = '2px';
|
|
||||||
this.style.right = '2px';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate start/end minutes from Y position
|
* Calculate start/end minutes from Y position
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,17 @@ export class DateEventRenderer implements EventRendererStrategy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderEvent(event: CalendarEvent): HTMLElement {
|
private renderEvent(event: CalendarEvent): HTMLElement {
|
||||||
return SwpEventElement.fromCalendarEvent(event);
|
const element = SwpEventElement.fromCalendarEvent(event);
|
||||||
|
|
||||||
|
// Apply positioning (moved from SwpEventElement.applyPositioning)
|
||||||
|
const position = this.calculateEventPosition(event);
|
||||||
|
element.style.position = 'absolute';
|
||||||
|
element.style.top = `${position.top + 1}px`;
|
||||||
|
element.style.height = `${position.height - 3}px`;
|
||||||
|
element.style.left = '2px';
|
||||||
|
element.style.right = '2px';
|
||||||
|
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected calculateEventPosition(event: CalendarEvent): { top: number; height: number } {
|
protected calculateEventPosition(event: CalendarEvent): { top: number; height: number } {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue