Skip to content

Commit 8ebbb35

Browse files
committed
fix: mouse position disjoint when sizing newly created event
1 parent eb72848 commit 8ebbb35

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/Week.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,15 @@ function getTotalTime(date: Date) {
410410
function createEvent() {
411411
const hoveredDay = getDateFromX(mousePosition.value.x);
412412
413+
// When creating an event, we fudge the initial mouse position so that
414+
// the start of the event is always at the beginning of the hovered interval
415+
const effectiveMouseY = floorToNearestInterval(mousePosition.value.y);
416+
413417
let start = getDateFromY(
414418
hoveredDay,
415-
floorToNearestInterval(mousePosition.value.y)
419+
effectiveMouseY
416420
);
421+
417422
if (isAfter(start, endOfDay(hoveredDay))) {
418423
return;
419424
}
@@ -423,7 +428,7 @@ function createEvent() {
423428
description: props.defaultEventProperties?.description,
424429
color: props.defaultEventProperties?.color ?? "#2196f3",
425430
startDate: start,
426-
endDate: addMinutes(start, props.intervalMinutes),
431+
endDate: start,
427432
nOfPreviousConcurrentEvents: 0,
428433
totalConcurrentEvents: 0,
429434
left: 0,
@@ -436,7 +441,7 @@ function createEvent() {
436441
initialEventState: { ...event },
437442
handle: "bottom",
438443
x: mousePosition.value.x,
439-
y: mousePosition.value.y + props.intervalHeight,
444+
y: effectiveMouseY,
440445
};
441446
creatingEvent = true;
442447
isDragging = true;

0 commit comments

Comments
 (0)