Snaps event resize to grid interval
Ensures that when resizing an event, the end time snaps to the defined grid interval, providing a more consistent user experience.
This commit is contained in:
parent
75d03fe577
commit
7a62ef7040
1 changed files with 7 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue