File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ class Toaster {
1717 for ( let i = this . toastQueue . length - 1 ; i >= 0 ; i -- ) {
1818 this . toastQueue [ i ] . duration -= deltaTime ;
1919 if ( this . toastQueue [ i ] . duration <= 0 ) {
20- this . toastQueue [ i ] . el . remove ( ) ;
20+ if ( this . toastQueue [ i ] . el . isConnected ) {
21+ this . toastQueue [ i ] . el . remove ( ) ;
22+ }
2123 this . toastQueue . splice ( i , 1 ) ;
2224 }
2325 }
@@ -50,6 +52,10 @@ class Toaster {
5052 el . classList . add ( ...toast . classes ) ;
5153 }
5254 toast . el = el ;
55+ toast . el . addEventListener ( "click" , ( ) => {
56+ toast . el . remove ( ) ;
57+ this . toastQueue . splice ( this . toastQueue . indexOf ( toast ) , 1 ) ;
58+ } ) ;
5359 this . toastQueue . push ( toast ) ;
5460 this . flip ( el ) ;
5561 }
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ toaster-component output{
2525 fade-out 0.3s 4.4s ease;
2626 animation-fill-mode : forwards;
2727 font-size : var (--font-sm );
28+ user-select : none;
29+ cursor : pointer;
30+ pointer-events : all;
31+ }
32+ toaster-component output : active {
33+ transform : scale (0.95 );
2834}
2935@keyframes fade-in {
3036 from { opacity : 0 }
You can’t perform that action at this time.
0 commit comments