You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/documentation/tutorial/12-actions/02-adding-parameters-to-act.../app-a/App.svelte

20 lines
420 B

<script>
import { longpress } from './longpress.js';
let pressed = false;
let duration = 2000;
</script>
<label>
<input type="range" bind:value duration} max={2000} step={100} />
{duration}ms
</label>
<button use:longpress on:longpress={() => (pressed = true)} on:mouseenter={() => (pressed = false)}
>press and hold</button
>
{#if pressed}
<p>congratulations, you pressed and held for {duration}ms</p>
{/if}