Discuss longpress action
Opened this issue · 2 comments
swyxio commented
export function longpress(node: HTMLElement, duration: number): ReturnType<Action>
Creates longpress
event when mousedown above duration
milliseconds.
Demo: https://svelte.dev/tutorial/adding-parameters-to-actions
<script>
import {longpress} from 'svelte-actions'
</script>
<button use:longpress={duration}
on:longpress="{() => pressed = true}"
on:mouseenter="{() => pressed = false}"
>press and hold</button>
tgf9 commented
Is there a way to prevent the regular click
event from firing after mouseup
? Currently when you release the mouse button, this will trigger the on:click
and on:longpress
callbacks.
swyxio commented
hmm maybe you can use stopimmediatepropagation? https://javascript.info/bubbling-and-capturing