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 {
17
17
for ( let i = this . toastQueue . length - 1 ; i >= 0 ; i -- ) {
18
18
this . toastQueue [ i ] . duration -= deltaTime ;
19
19
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
+ }
21
23
this . toastQueue . splice ( i , 1 ) ;
22
24
}
23
25
}
@@ -50,6 +52,10 @@ class Toaster {
50
52
el . classList . add ( ...toast . classes ) ;
51
53
}
52
54
toast . el = el ;
55
+ toast . el . addEventListener ( "click" , ( ) => {
56
+ toast . el . remove ( ) ;
57
+ this . toastQueue . splice ( this . toastQueue . indexOf ( toast ) , 1 ) ;
58
+ } ) ;
53
59
this . toastQueue . push ( toast ) ;
54
60
this . flip ( el ) ;
55
61
}
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ toaster-component output{
25
25
fade-out 0.3s 4.4s ease;
26
26
animation-fill-mode : forwards;
27
27
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 );
28
34
}
29
35
@keyframes fade-in {
30
36
from { opacity : 0 }
You can’t perform that action at this time.
0 commit comments