File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 33 */
44( ( ) => {
55 if ( window !== window . top ) return ;
6- const version = buildVersion ( 1 , 8 , 0 ) ;
6+ const version = buildVersion ( 1 , 9 , 0 ) ;
77 if ( window . SimpleToast ) {
88 if ( SimpleToast . version ) {
99 if ( SimpleToast . version >= version . number ) return ;
114114 pending += 1 ;
115115 return ;
116116 }
117- toast . close ( ) ;
117+ toast . timedout ( ) ;
118118 } ) ;
119119 if ( pending ) {
120120 startTimeout ( ) ;
154154 const body = document . createElement ( 'span' ) ;
155155 body . textContent = text ;
156156 el . appendChild ( body ) ;
157+ let closeType = 'unknown' ;
157158 const toast = {
158159 setText : ( newText ) => {
159160 if ( ! newText || ! toast . exists ( ) ) return ;
165166 root . removeChild ( el ) ;
166167 toasts . delete ( id ) ;
167168 if ( typeof onClose === 'function' ) {
168- onClose ( toast ) ;
169+ onClose ( toast , closeType ) ;
169170 }
170171 } ,
172+ timedout : ( ) => {
173+ closeType = 'timeout' ;
174+ toast . close ( ) ;
175+ } ,
176+ closed : ( ) => {
177+ closeType = 'dismissed' ;
178+ toast . close ( ) ;
179+ } ,
171180 } ;
172181 if ( timeout ) {
173182 toast . timeout = Date . now ( ) + timeout ;
208217 el . appendChild ( elb ) ;
209218 } ) ;
210219 }
211- el . addEventListener ( 'click' , toast . close ) ;
220+ el . addEventListener ( 'click' , toast . closed ) ;
212221
213222 root . appendChild ( el ) ;
214223 toasts . set ( id , toast ) ;
You can’t perform that action at this time.
0 commit comments