wip, resize, debugging

This commit is contained in:
Janus C. H. Knudsen 2025-10-08 00:58:38 +02:00
parent e2cf4d1e04
commit 8b8a1e3127
7 changed files with 289 additions and 9 deletions

View file

@ -126,6 +126,31 @@ export class SwpEventElement extends BaseSwpEventElement {
this.end = endDate;
}
/**
* Update event height during resize
* @param newHeight - The new height in pixels
*/
public updateHeight(newHeight: number): void {
// 1. Update visual height
this.style.height = `${newHeight}px`;
// 2. Calculate new end time based on height
const gridSettings = calendarConfig.getGridSettings();
const { hourHeight } = gridSettings;
// Get current start time
const start = this.start;
// Calculate duration from height
const durationMinutes = (newHeight / hourHeight) * 60;
// Calculate new end time by adding duration to start (using DateService for timezone safety)
const endDate = this.dateService.addMinutes(start, durationMinutes);
// 3. Update end attribute (triggers attributeChangedCallback → updateDisplay)
this.end = endDate;
}
/**
* Create a clone for drag operations
*/
@ -135,6 +160,9 @@ export class SwpEventElement extends BaseSwpEventElement {
// Apply "clone-" prefix to ID
clone.dataset.eventId = `clone-${this.eventId}`;
// Disable pointer events on clone so it doesn't interfere with hover detection
clone.style.pointerEvents = 'none';
// Cache original duration
const timeEl = this.querySelector('swp-event-time');
if (timeEl) {
@ -316,10 +344,13 @@ export class SwpAllDayEventElement extends BaseSwpEventElement {
*/
public createClone(): SwpAllDayEventElement {
const clone = this.cloneNode(true) as SwpAllDayEventElement;
// Apply "clone-" prefix to ID
clone.dataset.eventId = `clone-${this.eventId}`;
// Disable pointer events on clone so it doesn't interfere with hover detection
clone.style.pointerEvents = 'none';
return clone;
}