Skip to content

Commit e2047af

Browse files
authored
Revert "feat(datepicker): add animation to calendar popup" (#8976)
This reverts commit 3dca420.
1 parent 0388202 commit e2047af

File tree

4 files changed

+6
-115
lines changed

4 files changed

+6
-115
lines changed

src/lib/datepicker/datepicker-content.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
[maxDate]="datepicker._maxDate"
88
[dateFilter]="datepicker._dateFilter"
99
[selected]="datepicker._selected"
10-
[@fadeInCalendar]="'enter'"
1110
(selectedChange)="datepicker._select($event)"
1211
(_userSelection)="datepicker.close()">
1312
</mat-calendar>

src/lib/datepicker/datepicker-content.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,13 @@ $mat-datepicker-touch-max-height: 788px;
2828
@include mat-elevation(8);
2929

3030
display: block;
31-
transform-origin: top center;
3231

3332
.mat-calendar {
3433
width: $mat-datepicker-non-touch-calendar-width;
3534
height: $mat-datepicker-non-touch-calendar-height;
3635
}
3736
}
3837

39-
.mat-datepicker-content-above {
40-
transform-origin: bottom center;
41-
}
42-
4338
.mat-datepicker-content-touch {
4439
@include mat-elevation(0);
4540

src/lib/datepicker/datepicker.spec.ts

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
dispatchMouseEvent,
99
} from '@angular/cdk/testing';
1010
import {Component, ViewChild} from '@angular/core';
11-
import {async, ComponentFixture, inject, TestBed, fakeAsync, flush} from '@angular/core/testing';
11+
import {async, ComponentFixture, inject, TestBed} from '@angular/core/testing';
1212
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
1313
import {
1414
DEC,
@@ -167,7 +167,7 @@ describe('MatDatepicker', () => {
167167
expect(parseInt(getComputedStyle(popup).height as string)).toBe(0);
168168
});
169169

170-
it('should close the popup when pressing ESCAPE', fakeAsync(() => {
170+
it('should close the popup when pressing ESCAPE', () => {
171171
testComponent.datepicker.open();
172172
fixture.detectChanges();
173173

@@ -179,15 +179,14 @@ describe('MatDatepicker', () => {
179179

180180
dispatchEvent(content, keyboardEvent);
181181
fixture.detectChanges();
182-
flush();
183182

184183
content = document.querySelector('.cdk-overlay-pane mat-datepicker-content')!;
185184

186185
expect(content).toBeFalsy('Expected datepicker to be closed.');
187186
expect(stopPropagationSpy).toHaveBeenCalled();
188187
expect(keyboardEvent.defaultPrevented)
189188
.toBe(true, 'Expected default ESCAPE action to be prevented.');
190-
}));
189+
});
191190

192191
it('close should close dialog', async(() => {
193192
testComponent.touch = true;
@@ -1237,54 +1236,6 @@ describe('MatDatepicker', () => {
12371236
});
12381237
}));
12391238
});
1240-
1241-
describe('popup animations', () => {
1242-
let fixture: ComponentFixture<StandardDatepicker>;
1243-
let testComponent: StandardDatepicker;
1244-
1245-
beforeEach(fakeAsync(() => {
1246-
TestBed.configureTestingModule({
1247-
imports: [MatDatepickerModule, MatNativeDateModule, NoopAnimationsModule],
1248-
declarations: [StandardDatepicker],
1249-
}).compileComponents();
1250-
1251-
fixture = TestBed.createComponent(StandardDatepicker);
1252-
fixture.detectChanges();
1253-
testComponent = fixture.componentInstance;
1254-
}));
1255-
1256-
it('should not set the `mat-datepicker-content-above` class when opening downwards',
1257-
fakeAsync(() => {
1258-
fixture.componentInstance.datepicker.open();
1259-
fixture.detectChanges();
1260-
flush();
1261-
fixture.detectChanges();
1262-
1263-
const content =
1264-
document.querySelector('.cdk-overlay-pane mat-datepicker-content')! as HTMLElement;
1265-
1266-
expect(content.classList).not.toContain('mat-datepicker-content-above');
1267-
}));
1268-
1269-
it('should set the `mat-datepicker-content-above` class when opening upwards', fakeAsync(() => {
1270-
const input = fixture.debugElement.nativeElement.querySelector('input');
1271-
1272-
// Push the input to the bottom of the page to force the calendar to open upwards
1273-
input.style.position = 'fixed';
1274-
input.style.bottom = '0';
1275-
1276-
fixture.componentInstance.datepicker.open();
1277-
fixture.detectChanges();
1278-
flush();
1279-
fixture.detectChanges();
1280-
1281-
const content =
1282-
document.querySelector('.cdk-overlay-pane mat-datepicker-content')! as HTMLElement;
1283-
1284-
expect(content.classList).toContain('mat-datepicker-content-above');
1285-
}));
1286-
1287-
});
12881239
});
12891240

12901241

src/lib/datepicker/datepicker.ts

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
PositionStrategy,
1717
RepositionScrollStrategy,
1818
ScrollStrategy,
19-
ConnectedPositionStrategy,
2019
} from '@angular/cdk/overlay';
2120
import {ComponentPortal} from '@angular/cdk/portal';
2221
import {take} from 'rxjs/operators/take';
@@ -36,8 +35,6 @@ import {
3635
ViewChild,
3736
ViewContainerRef,
3837
ViewEncapsulation,
39-
ChangeDetectorRef,
40-
OnInit,
4138
} from '@angular/core';
4239
import {DateAdapter} from '@angular/material/core';
4340
import {MatDialog, MatDialogRef} from '@angular/material/dialog';
@@ -47,7 +44,6 @@ import {Subscription} from 'rxjs/Subscription';
4744
import {MatCalendar} from './calendar';
4845
import {createMissingDateImplError} from './datepicker-errors';
4946
import {MatDatepickerInput} from './datepicker-input';
50-
import{trigger, state, style, animate, transition} from '@angular/animations';
5147

5248

5349
/** Used to generate a unique ID for each datepicker instance. */
@@ -85,73 +81,23 @@ export const MAT_DATEPICKER_SCROLL_STRATEGY_PROVIDER = {
8581
styleUrls: ['datepicker-content.css'],
8682
host: {
8783
'class': 'mat-datepicker-content',
88-
'[@tranformPanel]': '"enter"',
8984
'[class.mat-datepicker-content-touch]': 'datepicker.touchUi',
90-
'[class.mat-datepicker-content-above]': '_isAbove',
9185
'(keydown)': '_handleKeydown($event)',
9286
},
93-
animations: [
94-
trigger('tranformPanel', [
95-
state('void', style({opacity: 0, transform: 'scale(1, 0)'})),
96-
state('enter', style({opacity: 1, transform: 'scale(1, 1)'})),
97-
transition('void => enter', animate('400ms cubic-bezier(0.25, 0.8, 0.25, 1)')),
98-
transition('* => void', animate('100ms linear', style({opacity: 0})))
99-
]),
100-
trigger('fadeInCalendar', [
101-
state('void', style({opacity: 0})),
102-
state('enter', style({opacity: 1})),
103-
transition('void => *', animate('400ms 100ms cubic-bezier(0.55, 0, 0.55, 0.2)'))
104-
])
105-
],
10687
exportAs: 'matDatepickerContent',
10788
encapsulation: ViewEncapsulation.None,
10889
preserveWhitespaces: false,
10990
changeDetection: ChangeDetectionStrategy.OnPush,
11091
})
111-
export class MatDatepickerContent<D> implements AfterContentInit, OnInit, OnDestroy {
112-
/** Subscription to changes in the overlay's position. */
113-
private _positionChange: Subscription|null;
114-
115-
/** Reference to the internal calendar component. */
116-
@ViewChild(MatCalendar) _calendar: MatCalendar<D>;
117-
118-
/** Reference to the datepicker that created the overlay. */
92+
export class MatDatepickerContent<D> implements AfterContentInit {
11993
datepicker: MatDatepicker<D>;
12094

121-
/** Whether the datepicker is above or below the input. */
122-
_isAbove: boolean;
123-
124-
constructor(private _changeDetectorRef: ChangeDetectorRef) {}
125-
126-
ngOnInit() {
127-
if (!this.datepicker._popupRef || this._positionChange) {
128-
return;
129-
}
130-
131-
const positionStrategy =
132-
this.datepicker._popupRef.getConfig().positionStrategy! as ConnectedPositionStrategy;
133-
134-
this._positionChange = positionStrategy.onPositionChange.subscribe(change => {
135-
const isAbove = change.connectionPair.overlayY === 'bottom';
136-
137-
if (isAbove !== this._isAbove) {
138-
this._isAbove = isAbove;
139-
this._changeDetectorRef.markForCheck();
140-
}
141-
});
142-
}
95+
@ViewChild(MatCalendar) _calendar: MatCalendar<D>;
14396

14497
ngAfterContentInit() {
14598
this._calendar._focusActiveCell();
14699
}
147100

148-
ngOnDestroy() {
149-
if (this._positionChange) {
150-
this._positionChange.unsubscribe();
151-
this._positionChange = null;
152-
}
153-
}
154-
155101
/**
156102
* Handles keydown event on datepicker content.
157103
* @param event The event.
@@ -268,7 +214,7 @@ export class MatDatepicker<D> implements OnDestroy {
268214
}
269215

270216
/** A reference to the overlay when the calendar is opened as a popup. */
271-
_popupRef: OverlayRef;
217+
private _popupRef: OverlayRef;
272218

273219
/** A reference to the dialog when the calendar is opened as a dialog. */
274220
private _dialogRef: MatDialogRef<any> | null;

0 commit comments

Comments
 (0)