Skip to content

Commit aa478ee

Browse files
authored
fix: can't resize into hours past midnight (#273)
2 parents 755ac4a + eb72848 commit aa478ee

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

src/components/Week.vue

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ import {
199199
addHours,
200200
differenceInDays,
201201
isSameDay,
202+
min,
203+
max
202204
} from "date-fns";
203205
import { guid } from "../helpers/Utility";
204206
@@ -340,28 +342,11 @@ function onMouseMove(mouseEvent: MouseEvent) {
340342
341343
const mouseDownColumnDate = getDateFromX(startX);
342344
343-
let max: Date;
344-
if (isSameDay(mouseDownColumnDate, initialState.endDate)) {
345-
max = endOfDay(mouseDownColumnDate);
346-
} else {
347-
max = startOfDay(addDays(initialState.startDate, 1));
348-
max = addHours(max, props.hoursPastMidnight);
349-
}
350-
351-
if (
352-
!isSameDay(startDate, initialState.startDate) ||
353-
(mouseDown.handle === "bottom" &&
354-
(isAfter(endDate, max) ||
355-
isBefore(
356-
endDate,
357-
addMinutes(mouseDownColumnDate, props.intervalMinutes)
358-
)))
359-
) {
360-
return;
361-
}
345+
const startOfNextDay = addDays(mouseDownColumnDate, 1);
346+
const max = addHours(startOfNextDay, props.hoursPastMidnight);
362347
363-
event.startDate = startDate;
364-
event.endDate = endDate;
348+
event.startDate = min([startDate, addMinutes(startOfNextDay, -props.intervalMinutes)]);
349+
event.endDate = min([endDate, max]);
365350
}
366351
}
367352

0 commit comments

Comments
 (0)