Skip to content

Commit

Permalink
fix(week-view): workaround js error when resizing events
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlewis92 committed Jan 23, 2019
1 parent 621c979 commit 94c51da
Showing 1 changed file with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,32 +791,34 @@ export class CalendarWeekViewComponent implements OnChanges, OnInit, OnDestroy {
allDayEvent
);

const allDayEventResizingBeforeStart = currentResize.edge === 'left';
let daysDiff: number;
if (allDayEventResizingBeforeStart) {
daysDiff = allDayEvent.offset - currentResize.originalOffset;
} else {
daysDiff = allDayEvent.span - currentResize.originalSpan;
}
if (currentResize) {
const allDayEventResizingBeforeStart = currentResize.edge === 'left';
let daysDiff: number;
if (allDayEventResizingBeforeStart) {
daysDiff = allDayEvent.offset - currentResize.originalOffset;
} else {
daysDiff = allDayEvent.span - currentResize.originalSpan;
}

allDayEvent.offset = currentResize.originalOffset;
allDayEvent.span = currentResize.originalSpan;
allDayEvent.offset = currentResize.originalOffset;
allDayEvent.span = currentResize.originalSpan;

let newStart: Date = allDayEvent.event.start;
let newEnd: Date = allDayEvent.event.end || allDayEvent.event.start;
if (allDayEventResizingBeforeStart) {
newStart = this.dateAdapter.addDays(newStart, daysDiff);
} else {
newEnd = this.dateAdapter.addDays(newEnd, daysDiff);
}
let newStart: Date = allDayEvent.event.start;
let newEnd: Date = allDayEvent.event.end || allDayEvent.event.start;
if (allDayEventResizingBeforeStart) {
newStart = this.dateAdapter.addDays(newStart, daysDiff);
} else {
newEnd = this.dateAdapter.addDays(newEnd, daysDiff);
}

this.eventTimesChanged.emit({
newStart,
newEnd,
event: allDayEvent.event,
type: CalendarEventTimesChangedEventType.Resize
});
this.allDayEventResizes.delete(allDayEvent);
this.eventTimesChanged.emit({
newStart,
newEnd,
event: allDayEvent.event,
type: CalendarEventTimesChangedEventType.Resize
});
this.allDayEventResizes.delete(allDayEvent);
}
}

/**
Expand Down

0 comments on commit 94c51da

Please sign in to comment.