diff --git a/src/elements/SwpEventElement.ts b/src/elements/SwpEventElement.ts index 5dc5367..60d27c3 100644 --- a/src/elements/SwpEventElement.ts +++ b/src/elements/SwpEventElement.ts @@ -136,16 +136,19 @@ export class SwpEventElement extends BaseSwpEventElement { // 2. Calculate new end time based on height const gridSettings = calendarConfig.getGridSettings(); - const { hourHeight } = gridSettings; + const { hourHeight, snapInterval } = gridSettings; // Get current start time const start = this.start; // Calculate duration from height - const durationMinutes = (newHeight / hourHeight) * 60; + const rawDurationMinutes = (newHeight / hourHeight) * 60; - // Calculate new end time by adding duration to start (using DateService for timezone safety) - const endDate = this.dateService.addMinutes(start, durationMinutes); + // Snap duration to grid interval (like drag & drop) + const snappedDurationMinutes = Math.round(rawDurationMinutes / snapInterval) * snapInterval; + + // Calculate new end time by adding snapped duration to start (using DateService for timezone safety) + const endDate = this.dateService.addMinutes(start, snappedDurationMinutes); // 3. Update end attribute (triggers attributeChangedCallback → updateDisplay) this.end = endDate;