@@ -40,6 +40,41 @@ function MdToastDirective($mdToast) {
40
40
* - For a toast action, use element with class `md-action`.
41
41
* - Add the class `md-capsule` for curved corners.
42
42
*
43
+ * ## Parent container notes
44
+ *
45
+ * The toast is positioned using absolute positioning relative to it's first non-static parent
46
+ * container. Thus, if the requested parent container uses static positioning, we will temporarily
47
+ * set it's positioning to `relative` while the toast is visible and reset it when the toast is
48
+ * hidden.
49
+ *
50
+ * Because of this, it is usually best to ensure that the parent container has a fixed height and
51
+ * prevents scrolling by setting the `overflow: hidden;` style. Since the position is based off of
52
+ * the parent's height, the toast may be mispositioned if you allow the parent to scroll.
53
+ *
54
+ * You can, however, have a scrollable element inside of the container; just make sure the
55
+ * container itself does not scroll.
56
+ *
57
+ * <hljs lang="html">
58
+ * <div layout-fill id="toast-container">
59
+ * <md-content>
60
+ * I can have lots of content and scroll!
61
+ * </md-content>
62
+ * </div>
63
+ * </hljs>
64
+ *
65
+ * Additionally, during animation, we will add the `md-toast-animating` class to the parent
66
+ * container. This defines a simple rule of `overflow: hidden !important;` to ensure that
67
+ * scrollbars are not visible on the parent during animation if you use a different overflow style.
68
+ *
69
+ * If you need to override this, you can use the following CSS, but be aware that it may cause
70
+ * scrollbars to intermittently appear.
71
+ *
72
+ * <hljs lang="css">
73
+ * .md-toast-animating {
74
+ * overflow: auto !important;
75
+ * }
76
+ * </hljs>
77
+ *
43
78
* @usage
44
79
* <hljs lang="html">
45
80
* <div ng-controller="MyController">
@@ -298,15 +333,20 @@ function MdToastProvider($$interimElementProvider) {
298
333
return 'md-' + pos ;
299
334
} ) . join ( ' ' ) ) ;
300
335
301
- return $animate . enter ( element , options . parent ) ;
336
+ if ( options . parent ) options . parent . addClass ( 'md-toast-animating' ) ;
337
+ return $animate . enter ( element , options . parent ) . then ( function ( ) {
338
+ if ( options . parent ) options . parent . removeClass ( 'md-toast-animating' ) ;
339
+ } ) ;
302
340
}
303
341
304
342
function onRemove ( scope , element , options ) {
305
343
element . off ( SWIPE_EVENTS , options . onSwipe ) ;
344
+ if ( options . parent ) options . parent . addClass ( 'md-toast-animating' ) ;
306
345
if ( options . openClass ) options . parent . removeClass ( options . openClass ) ;
307
346
308
347
return ( ( options . $destroy == true ) ? element . remove ( ) : $animate . leave ( element ) )
309
348
. then ( function ( ) {
349
+ if ( options . parent ) options . parent . removeClass ( 'md-toast-animating' ) ;
310
350
if ( $mdUtil . hasComputedStyle ( options . parent , 'position' , 'static' ) ) {
311
351
options . parent . css ( 'position' , '' ) ;
312
352
}
0 commit comments