@@ -174,19 +174,9 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
174
174
/** Emits whenever the drawer has started animating. */
175
175
_animationStarted = new EventEmitter < AnimationEvent > ( ) ;
176
176
177
- /** Whether the drawer is animating. Used to prevent overlapping animations. */
178
- _isAnimating = false ;
179
-
180
177
/** Current state of the sidenav animation. */
181
178
_animationState : 'open-instant' | 'open' | 'void' = 'void' ;
182
179
183
- /**
184
- * Promise that resolves when the open/close animation completes. It is here for backwards
185
- * compatibility and should be removed next time we do drawer breaking changes.
186
- * @deprecated
187
- */
188
- private _currentTogglePromise : Promise < MatDrawerToggleResult > | null ;
189
-
190
180
/** Event emitted when the drawer is fully opened. */
191
181
@Output ( 'open' ) onOpen = new EventEmitter < MatDrawerToggleResult | void > ( ) ;
192
182
@@ -281,27 +271,23 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
281
271
* @param isOpen Whether the drawer should be open.
282
272
*/
283
273
toggle ( isOpen : boolean = ! this . opened ) : Promise < MatDrawerToggleResult > {
284
- if ( ! this . _isAnimating ) {
285
- this . _opened = isOpen ;
274
+ this . _opened = isOpen ;
286
275
287
- if ( isOpen ) {
288
- this . _animationState = this . _enableAnimations ? 'open' : 'open-instant' ;
289
- } else {
290
- this . _animationState = 'void' ;
291
- }
292
-
293
- this . _currentTogglePromise = new Promise ( resolve => {
294
- first . call ( isOpen ? this . onOpen : this . onClose ) . subscribe ( resolve ) ;
295
- } ) ;
276
+ if ( isOpen ) {
277
+ this . _animationState = this . _enableAnimations ? 'open' : 'open-instant' ;
278
+ } else {
279
+ this . _animationState = 'void' ;
280
+ }
296
281
297
- if ( this . _focusTrap ) {
298
- this . _focusTrap . enabled = this . _isFocusTrapEnabled ;
299
- }
282
+ if ( this . _focusTrap ) {
283
+ this . _focusTrap . enabled = this . _isFocusTrapEnabled ;
300
284
}
301
285
302
286
// TODO(crisbeto): This promise is here for backwards-compatibility.
303
287
// It should be removed next time we do breaking changes in the drawer.
304
- return this . _currentTogglePromise ! ;
288
+ return new Promise ( resolve => {
289
+ first . call ( isOpen ? this . onOpen : this . onClose ) . subscribe ( resolve ) ;
290
+ } ) ;
305
291
}
306
292
307
293
/**
@@ -316,7 +302,6 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
316
302
}
317
303
318
304
_onAnimationStart ( event : AnimationEvent ) {
319
- this . _isAnimating = true ;
320
305
this . _animationStarted . emit ( event ) ;
321
306
}
322
307
@@ -328,14 +313,6 @@ export class MatDrawer implements AfterContentInit, OnDestroy {
328
313
} else if ( toState === 'void' && fromState . indexOf ( 'open' ) === 0 ) {
329
314
this . onClose . emit ( new MatDrawerToggleResult ( 'close' , true ) ) ;
330
315
}
331
-
332
- // Note: as of Angular 4.3, the animations module seems to fire the `start` callback before
333
- // the end if animations are disabled. Make this call async to ensure that it still fires
334
- // at the appropriate time.
335
- Promise . resolve ( ) . then ( ( ) => {
336
- this . _isAnimating = false ;
337
- this . _currentTogglePromise = null ;
338
- } ) ;
339
316
}
340
317
341
318
get _width ( ) {
0 commit comments