File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 38
38
this . actionHandler_ = undefined ;
39
39
this . message_ = undefined ;
40
40
this . actionText_ = undefined ;
41
+ this . timeoutID_ = undefined ;
41
42
this . queuedNotifications_ = [ ] ;
42
43
this . setActionHidden_ ( true ) ;
43
44
} ;
86
87
this . textElement_ . textContent = this . message_ ;
87
88
this . element_ . classList . add ( this . cssClasses_ . ACTIVE ) ;
88
89
this . element_ . setAttribute ( 'aria-hidden' , 'false' ) ;
89
- setTimeout ( this . cleanup_ . bind ( this ) , this . timeout_ ) ;
90
+ this . timeoutID_ = setTimeout ( this . cleanup_ . bind ( this ) , this . timeout_ ) ;
90
91
91
92
} ;
92
93
127
128
}
128
129
} ;
129
130
MaterialSnackbar . prototype [ 'showSnackbar' ] = MaterialSnackbar . prototype . showSnackbar ;
130
-
131
+ /**
132
+ * Hide the snackbar.
133
+ *
134
+ * @public
135
+ */
136
+ MaterialSnackbar . prototype . hideSnackbar = function ( ) {
137
+ if ( ! this . active ) {
138
+ return ;
139
+ }
140
+ if ( typeof this . timeoutID_ === 'number' ) {
141
+ clearTimeout ( this . timeoutID_ ) ;
142
+ this . cleanup_ ( ) ;
143
+ }
144
+ } ;
145
+ MaterialSnackbar . prototype [ 'hideSnackbar' ] = MaterialSnackbar . prototype . hideSnackbar ;
131
146
/**
132
147
* Check if the queue has items within it.
133
148
* If it does, display the next entry.
158
173
this . actionHandler_ = undefined ;
159
174
this . message_ = undefined ;
160
175
this . actionText_ = undefined ;
176
+ this . timeoutID_ = undefined ;
161
177
this . active = false ;
162
178
this . checkQueue_ ( ) ;
163
179
} . bind ( this ) , /** @type {number } */ ( this . Constant_ . ANIMATION_LENGTH ) ) ;
You can’t perform that action at this time.
0 commit comments