Enhances event drag and resize functionality
Improves event dragging by tracking the source column and using the updated event data for re-rendering affected columns. Also, enhances event resizing by updating the event data and re-rendering the column to recalculate stacking/grouping. Uses snap interval as minimum duration when resizing.
This commit is contained in:
parent
e83753a7d2
commit
ecb1729c28
4 changed files with 154 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { eventBus } from '../core/EventBus';
|
||||
import { CoreEvents } from '../constants/CoreEvents';
|
||||
import { calendarConfig } from '../core/CalendarConfig';
|
||||
import { ResizeEndEventPayload } from '../types/EventTypes';
|
||||
|
||||
type SwpEventEl = HTMLElement & { updateHeight?: (h: number) => void };
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ export class ResizeHandleManager {
|
|||
const grid = calendarConfig.getGridSettings();
|
||||
this.hourHeightPx = grid.hourHeight;
|
||||
this.snapMin = grid.snapInterval;
|
||||
this.minDurationMin = grid.minEventDuration ?? this.snapMin;
|
||||
this.minDurationMin = this.snapMin; // Use snap interval as minimum duration
|
||||
}
|
||||
|
||||
public initialize(): void {
|
||||
|
|
@ -232,6 +233,15 @@ export class ResizeHandleManager {
|
|||
|
||||
this.targetEl.updateHeight?.(finalHeight);
|
||||
|
||||
// Emit resize:end event for re-stacking
|
||||
const eventId = this.targetEl.dataset.eventId || '';
|
||||
const resizeEndPayload: ResizeEndEventPayload = {
|
||||
eventId,
|
||||
element: this.targetEl,
|
||||
finalHeight
|
||||
};
|
||||
eventBus.emit('resize:end', resizeEndPayload);
|
||||
|
||||
const group = this.targetEl.closest<HTMLElement>('swp-event-group') ?? this.targetEl;
|
||||
group.style.zIndex = this.prevZ ?? '';
|
||||
this.prevZ = undefined;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue