preload on focusin as well

pull/17004/head
Rich Harris 4 weeks ago
parent 1b5ff6b60a
commit f811633ef4

@ -148,18 +148,24 @@ The [`fork(...)`](svelte#fork) API, added in 5.42, makes it possible to run `awa
/** @type {import('svelte').Fork | null} */ /** @type {import('svelte').Fork | null} */
let pending = null; let pending = null;
</script>
<button function preload() {
onpointerenter={() => {
pending ??= fork(() => { pending ??= fork(() => {
open = true; open = true;
}); });
}} }
onpointerleave={() => {
function discard() {
pending?.discard(); pending?.discard();
pending = null; pending = null;
}} }
</script>
<button
onfocusin={preload}
onfocusout={discard}
onpointerenter={preload}
onpointerleave={discard}
onclick={() => { onclick={() => {
pending?.commit(); pending?.commit();
pending = null; pending = null;

Loading…
Cancel
Save