@@ -18,7 +18,7 @@ import {
1818import { takeUntil , startWith } from 'rxjs/operators' ;
1919import { Subject } from 'rxjs' ;
2020
21- import { EventRegistry , isBrowser , toBoolean } from '@angular-mdc/web/common' ;
21+ import { isBrowser , toBoolean } from '@angular-mdc/web/common' ;
2222
2323import {
2424 MdcAppBarActionItem ,
@@ -41,7 +41,6 @@ export class MdcAppBarNavSelected {
4141 selector : '[mdc-app-bar], mdc-app-bar' ,
4242 template : '<ng-content></ng-content>' ,
4343 exportAs : 'mdcAppBar' ,
44- providers : [ EventRegistry ] ,
4544 changeDetection : ChangeDetectionStrategy . OnPush ,
4645 encapsulation : ViewEncapsulation . None
4746} )
@@ -58,7 +57,7 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
5857 this . setFixed ( value ) ;
5958 }
6059 }
61- protected _fixed : boolean ;
60+ private _fixed : boolean ;
6261
6362 @Input ( )
6463 get prominent ( ) : boolean { return this . _prominent ; }
@@ -67,7 +66,7 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
6766 this . setProminent ( value ) ;
6867 }
6968 }
70- protected _prominent : boolean ;
69+ private _prominent : boolean ;
7170
7271 @Input ( )
7372 get short ( ) : boolean { return this . _short ; }
@@ -76,7 +75,7 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
7675 this . setShort ( value ) ;
7776 }
7877 }
79- protected _short : boolean ;
78+ private _short : boolean ;
8079
8180 @Input ( )
8281 get shortCollapsed ( ) : boolean { return this . _shortCollapsed ; }
@@ -85,7 +84,7 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
8584 this . setShortCollapsed ( value ) ;
8685 }
8786 }
88- protected _shortCollapsed : boolean ;
87+ private _shortCollapsed : boolean ;
8988
9089 @Input ( )
9190 get dense ( ) : boolean { return this . _dense ; }
@@ -94,7 +93,7 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
9493 this . setDense ( value ) ;
9594 }
9695 }
97- protected _dense : boolean ;
96+ private _dense : boolean ;
9897
9998 @Input ( )
10099 get fixedAdjustElement ( ) : HTMLElement { return this . _fixedAdjustElement ; }
@@ -103,7 +102,7 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
103102 this . setFixedAdjustElement ( element ) ;
104103 }
105104 }
106- protected _fixedAdjustElement : HTMLElement ;
105+ private _fixedAdjustElement : HTMLElement ;
107106
108107 /** Event emitted when the navigation icon is selected. */
109108 @Output ( ) navigationSelected : EventEmitter < MdcAppBarNavSelected > = new EventEmitter < MdcAppBarNavSelected > ( ) ;
@@ -140,22 +139,22 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
140139 registerScrollHandler : ( handler : EventListener ) => {
141140 if ( ! isBrowser ( ) ) { return ; }
142141
143- this . _registry . listen ( 'scroll' , handler , window ) ;
142+ window . addEventListener ( 'scroll' , handler ) ;
144143 } ,
145144 deregisterScrollHandler : ( handler : EventListener ) => {
146145 if ( ! isBrowser ( ) ) { return ; }
147146
148- this . _registry . unlisten ( 'scroll' , handler ) ;
147+ window . removeEventListener ( 'scroll' , handler ) ;
149148 } ,
150149 registerResizeHandler : ( handler : EventListener ) => {
151150 if ( ! isBrowser ( ) ) { return ; }
152151
153- this . _registry . listen ( 'resize' , handler , window ) ;
152+ window . addEventListener ( 'resize' , handler ) ;
154153 } ,
155154 deregisterResizeHandler : ( handler : EventListener ) => {
156155 if ( ! isBrowser ( ) ) { return ; }
157156
158- this . _registry . unlisten ( 'resize' , handler ) ;
157+ window . removeEventListener ( 'resize' , handler ) ;
159158 } ,
160159 getViewportScrollY : ( ) => {
161160 if ( ! isBrowser ( ) ) { return 0 ; }
@@ -172,8 +171,7 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
172171
173172 constructor (
174173 private _changeDetectorRef : ChangeDetectorRef ,
175- public elementRef : ElementRef ,
176- private _registry : EventRegistry ) { }
174+ public elementRef : ElementRef ) { }
177175
178176 ngAfterContentInit ( ) : void {
179177 this . actions . changes . pipe ( startWith ( null ) , takeUntil ( this . _destroy ) ) . subscribe ( ( ) => {
@@ -194,7 +192,9 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
194192 this . _destroy . next ( ) ;
195193 this . _destroy . complete ( ) ;
196194
197- this . _foundation . destroy ( ) ;
195+ if ( this . _foundation ) {
196+ this . _foundation . destroy ( ) ;
197+ }
198198 }
199199
200200 setFixedAdjustElement ( element : HTMLElement ) : void {
@@ -272,23 +272,27 @@ export class MdcAppBar implements AfterContentInit, AfterViewInit, OnDestroy {
272272 }
273273
274274 initializeFoundation ( ) : void {
275- this . _foundation . destroy ( ) ;
275+ setTimeout ( ( ) => {
276+ this . _foundation . destroy ( ) ;
276277
277- this . _getHostElement ( ) . style . top = '0px' ;
278- this . _resetFixedShort ( ) ;
278+ this . _getHostElement ( ) . style . top = '0px' ;
279+ this . _resetFixedShort ( ) ;
279280
280- if ( this . short ) {
281- this . _foundation = new MDCShortTopAppBarFoundation ( this . _mdcAdapter ) ;
282- } else if ( this . fixed ) {
283- this . _foundation = new MDCFixedTopAppBarFoundation ( this . _mdcAdapter ) ;
284- } else {
285- this . _foundation = new MDCTopAppBarFoundation ( this . _mdcAdapter ) ;
286- }
281+ if ( this . short ) {
282+ this . _foundation = new MDCShortTopAppBarFoundation ( this . _mdcAdapter ) ;
283+ } else if ( this . fixed ) {
284+ this . _foundation = new MDCFixedTopAppBarFoundation ( this . _mdcAdapter ) ;
285+ } else {
286+ this . _foundation = new MDCTopAppBarFoundation ( this . _mdcAdapter ) ;
287+ }
287288
288- this . _foundation . init ( ) ;
289- this . _isFoundationInit = true ;
289+ this . _foundation . init ( ) ;
290+ this . _isFoundationInit = true ;
290291
291- this . _initAppBar ( ) ;
292+ this . _initAppBar ( ) ;
293+
294+ this . _changeDetectorRef . markForCheck ( ) ;
295+ } , 20 ) ;
292296 }
293297
294298 private _resetFixedShort ( ) : void {
0 commit comments