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