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
1414let cprops = {}
1515/** @type {any} */
1616let unlisten
17+ /** @type {MouseEvent | KeyboardEvent} */
18+ let event
1719
1820const progress = tweened (item .initial , { duration: item .duration , easing: linear })
1921
20- function close (details ) {
21- item .details = details
22+ /** @param {MouseEvent|KeyboardEvent|undefined} [ev] */
23+ function close (ev ) {
24+ if (ev) event = ev
2225 toast .pop (item .id )
2326}
2427
2528function autoclose () {
26- if ($progress === 1 || $progress === 0 )
27- close ({
28- autoClose: true ,
29- originalEvent: null
30- })
29+ if ($progress === 1 || $progress === 0 ) close ()
3130}
3231
3332function pause () {
@@ -80,10 +79,7 @@ $: if (!check(item.progress)) {
8079onMount (listen)
8180
8281onDestroy (() => {
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 })
8783 unlisten && unlisten ()
8884})
8985 </script >
@@ -109,13 +105,9 @@ onDestroy(() => {
109105 class =" _toastBtn pe"
110106 role =" button"
111107 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 )
119111 }}
120112 />
121113 {/if }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import { writable } from 'svelte/store'
1818/**
1919 * @callback SvelteToastOnPopCallback
2020 * @param {number } [id] - optionally get the toast id if needed
21+ * @param {object } [details]
2122 */
2223
2324/**
You can’t perform that action at this time.
0 commit comments