Skip to content

Commit 5f0f6be

Browse files
committed
fix(week-view): respect minimumEventHeight input when resizing
BREAKING CHANGE: Previously when resizing events the minimum event height would be calculated based on `hourSegments`, `hourSegmentHeight` and `hourDuration`. It now respects the `minimumEventHeight` input instead. To restore the old behaviour you will need to set `minimumEventHeight` appropriately (by default it's `30` so should continue to work as expected for most users)
1 parent acf93a3 commit 5f0f6be

File tree

4 files changed

+8
-25
lines changed

4 files changed

+8
-25
lines changed

projects/angular-calendar/src/modules/common/util.ts

-11
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,6 @@ export function getMinutesMoved(
9999
return draggedInPixelsSnapSize * pixelAmountInMinutes;
100100
}
101101

102-
export function getMinimumEventHeightInMinutes(
103-
hourSegments: number,
104-
hourSegmentHeight: number,
105-
hourDuration?: number
106-
) {
107-
return (
108-
getPixelAmountInMinutes(hourSegments, hourSegmentHeight, hourDuration) *
109-
hourSegmentHeight
110-
);
111-
}
112-
113102
export function getDefaultEventEnd(
114103
dateAdapter: DateAdapter,
115104
event: CalendarEvent,

projects/angular-calendar/src/modules/week/calendar-week-view.component.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import {
4242
trackByHour,
4343
getMinutesMoved,
4444
getDefaultEventEnd,
45-
getMinimumEventHeightInMinutes,
4645
addDaysWithExclusions,
4746
isDraggedWithinPeriod,
4847
shouldFireDroppedEvent,
@@ -1328,29 +1327,24 @@ export class CalendarWeekViewComponent
13281327
calendarEvent: CalendarEvent,
13291328
resizeEvent: ResizeEvent
13301329
) {
1331-
const minimumEventHeight = getMinimumEventHeightInMinutes(
1332-
this.hourSegments,
1333-
this.hourSegmentHeight,
1334-
this.hourDuration
1335-
);
13361330
const newEventDates = {
13371331
start: calendarEvent.start,
13381332
end: getDefaultEventEnd(
13391333
this.dateAdapter,
13401334
calendarEvent,
1341-
minimumEventHeight
1335+
this.minimumEventHeight
13421336
),
13431337
};
13441338
const { end, ...eventWithoutEnd } = calendarEvent;
13451339
const smallestResizes = {
13461340
start: this.dateAdapter.addMinutes(
13471341
newEventDates.end,
1348-
minimumEventHeight * -1
1342+
this.minimumEventHeight * -1
13491343
),
13501344
end: getDefaultEventEnd(
13511345
this.dateAdapter,
13521346
eventWithoutEnd,
1353-
minimumEventHeight
1347+
this.minimumEventHeight
13541348
),
13551349
};
13561350

projects/angular-calendar/test/calendar-day-view.component.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,10 @@ describe('CalendarDayViewComponent component', () => {
561561
);
562562
fixture.componentInstance.viewDate = new Date('2016-06-27');
563563
fixture.componentInstance.hourSegments = 4;
564+
fixture.componentInstance.minimumEventHeight = 15;
564565
fixture.componentInstance.events = [
565566
{
566567
title: 'foo',
567-
color: { primary: '', secondary: '' },
568568
start: moment('2016-06-27').add(4, 'hours').toDate(),
569569
resizable: {
570570
afterEnd: true,

projects/angular-calendar/test/calendar-week-view.component.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3090,7 +3090,7 @@ describe('calendarWeekView component', () => {
30903090
clientY: rect.bottom - 200,
30913091
});
30923092
fixture.detectChanges();
3093-
expect(event.getBoundingClientRect().height).to.equal(20);
3093+
expect(event.getBoundingClientRect().height).to.equal(1);
30943094
triggerDomEvent('mouseup', document.body, {
30953095
clientX: rect.right,
30963096
clientY: rect.bottom - 200,
@@ -3102,7 +3102,7 @@ describe('calendarWeekView component', () => {
31023102
event: fixture.componentInstance.events[0],
31033103
newStart: fixture.componentInstance.events[0].start,
31043104
newEnd: moment(fixture.componentInstance.events[0].start)
3105-
.add(30, 'minutes')
3105+
.add(1, 'minutes')
31063106
.toDate(),
31073107
});
31083108
});
@@ -3159,7 +3159,7 @@ describe('calendarWeekView component', () => {
31593159
clientY: rect.bottom - 120,
31603160
});
31613161
fixture.detectChanges();
3162-
expect(event.getBoundingClientRect().height).to.equal(20);
3162+
expect(event.getBoundingClientRect().height).to.equal(1);
31633163
triggerDomEvent('mouseup', document.body, {
31643164
clientX: rect.right,
31653165
clientY: rect.bottom - 120,
@@ -3171,7 +3171,7 @@ describe('calendarWeekView component', () => {
31713171
event: fixture.componentInstance.events[0],
31723172
newStart: fixture.componentInstance.events[0].start,
31733173
newEnd: moment(fixture.componentInstance.events[0].start)
3174-
.add(20, 'minutes')
3174+
.add(1, 'minutes')
31753175
.toDate(),
31763176
});
31773177
});

0 commit comments

Comments
 (0)