File tree Expand file tree Collapse file tree 2 files changed +11
-18
lines changed Expand file tree Collapse file tree 2 files changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -14,20 +14,19 @@ let paused = false
14
14
let cprops = {}
15
15
/** @type {any} */
16
16
let unlisten
17
+ /** @type {MouseEvent | KeyboardEvent} */
18
+ let event
17
19
18
20
const progress = tweened (item .initial , { duration: item .duration , easing: linear })
19
21
20
- function close (details ) {
21
- item .details = details
22
+ /** @param {MouseEvent|KeyboardEvent|undefined} [ev] */
23
+ function close (ev ) {
24
+ if (ev) event = ev
22
25
toast .pop (item .id )
23
26
}
24
27
25
28
function autoclose () {
26
- if ($progress === 1 || $progress === 0 )
27
- close ({
28
- autoClose: true ,
29
- originalEvent: null
30
- })
29
+ if ($progress === 1 || $progress === 0 ) close ()
31
30
}
32
31
33
32
function pause () {
@@ -80,10 +79,7 @@ $: if (!check(item.progress)) {
80
79
onMount (listen)
81
80
82
81
onDestroy (() => {
83
- if (check (item .onpop , ' function' )) {
84
- // @ts-ignore
85
- item .onpop (item .id , item .details )
86
- }
82
+ item .onpop && item .onpop (item .id , { event })
87
83
unlisten && unlisten ()
88
84
})
89
85
</script >
@@ -109,13 +105,9 @@ onDestroy(() => {
109
105
class =" _toastBtn pe"
110
106
role =" button"
111
107
tabindex =" 0"
112
- on:click ={(ev ) =>
113
- close ({
114
- autoClose: false ,
115
- originalEvent: ev
116
- })}
117
- on:keydown ={(e ) => {
118
- if (e instanceof KeyboardEvent && [' Enter' , ' ' ].includes (e .key )) close (e )
108
+ on:click ={(ev ) => close (ev )}
109
+ on:keydown ={(ev ) => {
110
+ if (ev instanceof KeyboardEvent && [' Enter' , ' ' ].includes (ev .key )) close (ev )
119
111
}}
120
112
/>
121
113
{/if }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { writable } from 'svelte/store'
18
18
/**
19
19
* @callback SvelteToastOnPopCallback
20
20
* @param {number } [id] - optionally get the toast id if needed
21
+ * @param {object } [details]
21
22
*/
22
23
23
24
/**
You can’t perform that action at this time.
0 commit comments