File tree 1 file changed +16
-10
lines changed
projects/igniteui-angular/src/lib/calendar
1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -117,16 +117,22 @@ export class IgxCalendarComponent extends IgxMonthPickerBase implements AfterVie
117
117
}
118
118
119
119
set monthsViewNumber ( val : number ) {
120
- this . _monthsViewNumber = val ;
121
-
122
- for ( let i = 1 ; i < val ; i ++ ) {
123
- const nextMonthDate = new Date ( this . viewDate ) ;
124
- nextMonthDate . setMonth ( nextMonthDate . getMonth ( ) + i ) ;
125
- const monthView : IMonthView = {
126
- value : null ,
127
- viewDate : nextMonthDate
128
- } ;
129
- this . dayViews . push ( monthView ) ;
120
+ if ( this . _monthsViewNumber === val || val === 0 ) {
121
+ return ;
122
+ } else if ( this . _monthsViewNumber < val ) {
123
+ for ( let i = this . _monthsViewNumber ; i < val ; i ++ ) {
124
+ const nextMonthDate = new Date ( this . viewDate ) ;
125
+ nextMonthDate . setMonth ( nextMonthDate . getMonth ( ) + i ) ;
126
+ const monthView : IMonthView = {
127
+ value : null ,
128
+ viewDate : nextMonthDate
129
+ } ;
130
+ this . dayViews . push ( monthView ) ;
131
+ }
132
+ this . _monthsViewNumber = val ;
133
+ } else {
134
+ this . dayViews . splice ( val , this . dayViews . length - val ) ;
135
+ this . _monthsViewNumber = val ;
130
136
}
131
137
}
132
138
You can’t perform that action at this time.
0 commit comments