Improves drag and resize behavior

Prevents drag initiation when clicking on the resize handle of an event.
Reduces event height to prevent overlap with time gridlines.
This commit is contained in:
Janus C. H. Knudsen 2025-10-08 19:35:29 +02:00
parent 7a62ef7040
commit ce0a9b19eb
2 changed files with 12 additions and 12 deletions

View file

@ -183,16 +183,16 @@ export class DragDropManager {
// Found an event - check if in resize zone first
if (eventElement) {
// Check if click is in bottom resize zone
const rect = eventElement.getBoundingClientRect();
const mouseY = event.clientY;
const distanceFromBottom = rect.bottom - mouseY;
const resizeZoneHeight = 15; // Match ResizeHandleManager
// If in resize zone, don't handle this - let ResizeHandleManager take over
if (distanceFromBottom >= 0 && distanceFromBottom <= resizeZoneHeight) {
return; // Exit early - this is a resize operation
if (eventElement.tagName === 'SWP-EVENT') {
const rect = eventElement.getBoundingClientRect();
const mouseY = event.clientY;
const distanceFromBottom = rect.bottom - mouseY;
const resizeZoneHeight = 15; // Match ResizeHandleManager
// If in resize zone, don't handle this - let ResizeHandleManager take over
if (distanceFromBottom >= 0 && distanceFromBottom <= resizeZoneHeight) {
return; // Exit early - this is a resize operation
}
}
// Normal drag - prepare for potential dragging
this.draggedElement = eventElement;
this.lastColumn = ColumnDetectionUtils.getColumnBounds(this.lastMousePosition)
@ -671,7 +671,7 @@ export class DragDropManager {
// Check if mouse is still within the current hovered event
const isStillInside = mouseX >= rect.left && mouseX <= rect.right &&
mouseY >= rect.top && mouseY <= rect.bottom;
mouseY >= rect.top && mouseY <= rect.bottom;
// If mouse left the event
if (!isStillInside) {

View file

@ -208,7 +208,7 @@ export class ResizeHandleManager {
const snapDistancePx = (this.snapIntervalMinutes / 60) * this.hourHeightPx;
const currentHeight = this.resizingElement.offsetHeight;
const snappedHeight = Math.round(currentHeight / snapDistancePx) * snapDistancePx;
const finalHeight = Math.max(30, snappedHeight);
const finalHeight = Math.max(30, snappedHeight) - 3; //a little gap, so it doesn't cover the horizontal time lines
const swpEvent = this.resizingElement as any;
if (swpEvent.updateHeight) {