Skip to content

Commit

Permalink
fix(calendar): keep track of month changes #4282
Browse files Browse the repository at this point in the history
  • Loading branch information
hanastasov committed Sep 11, 2019
1 parent 7bc95a5 commit 74eeda2
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions projects/igniteui-angular/src/lib/calendar/calendar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {
ElementRef,
AfterViewInit,
ViewChildren,
QueryList,
AfterViewChecked
QueryList
} from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { fadeIn, scaleInCenter } from '../animations/main';
Expand Down Expand Up @@ -70,7 +69,7 @@ export interface IMonthView {
selector: 'igx-calendar',
templateUrl: 'calendar.component.html'
})
export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterViewInit, AfterViewChecked {
export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterViewInit {
/**
* Sets/gets the `id` of the calendar.
* If not set, the `id` will have value `"igx-calendar-0"`.
Expand Down Expand Up @@ -388,15 +387,6 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
});
}

public ngAfterViewChecked() {
this.monthViews.forEach((item, index) => {
const prevMonthView = this.getMonthView(index - 1);
const nextMonthView = this.getMonthView(index + 1);
item.nextMonthView = nextMonthView;
item.prevMonthView = prevMonthView;
});
}

/**
* Returns the locale representation of the month in the month view if enabled,
* otherwise returns the default `Date.getMonth()` value.
Expand All @@ -415,9 +405,6 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
*/
public previousMonth(isKeydownTrigger = false) {
this.viewDate = this.calendarModel.timedelta(this.viewDate, 'month', -1);
// this.dayViews.forEach((val) => {
// val.viewDate = this.calendarModel.timedelta(val.viewDate, 'month', -1);
// });
this._monthAction = 'prev';

if (this.daysView) {
Expand All @@ -430,9 +417,6 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
*/
public nextMonth(isKeydownTrigger = false) {
this.viewDate = this.calendarModel.timedelta(this.viewDate, 'month', 1);
// this.dayViews.forEach((val) => {
// val.viewDate = this.calendarModel.timedelta(val.viewDate, 'month', 1);
// });
this._monthAction = 'next';

if (this.daysView) {
Expand Down Expand Up @@ -558,10 +542,6 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
*/
public changeMonth(event: Date) {
this.viewDate = new Date(this.viewDate.getFullYear(), event.getMonth());
// this.dayViews.forEach((val, index) => {
// // val.viewDate.setMonth(event.getMonth() + index);
// val.viewDate = this.calendarModel.timedelta(val.viewDate, 'month', index);
// });

this.activeView = CalendarView.DEFAULT;

Expand Down

0 comments on commit 74eeda2

Please sign in to comment.