mirror of https://github.com/sveltejs/svelte
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.
22 lines
433 B
22 lines
433 B
6 years ago
|
<script>
|
||
5 years ago
|
import { longpress } from './longpress.js';
|
||
6 years ago
|
|
||
5 years ago
|
let pressed = false;
|
||
|
let duration = 2000;
|
||
|
</script>
|
||
6 years ago
|
|
||
5 years ago
|
<label>
|
||
1 year ago
|
<input type="range" bind:value={duration} max={2000} step={100} />
|
||
5 years ago
|
{duration}ms
|
||
|
</label>
|
||
6 years ago
|
|
||
1 year ago
|
<button
|
||
|
use:longpress={duration}
|
||
|
on:longpress={() => (pressed = true)}
|
||
|
on:mouseenter={() => (pressed = false)}>press and hold</button
|
||
|
>
|
||
6 years ago
|
|
||
5 years ago
|
{#if pressed}
|
||
|
<p>congratulations, you pressed and held for {duration}ms</p>
|
||
1 year ago
|
{/if}
|