Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discuss longpress action #3

Open
swyxio opened this issue Nov 1, 2020 · 2 comments
Open

Discuss longpress action #3

swyxio opened this issue Nov 1, 2020 · 2 comments

Comments

@swyxio
Copy link
Owner

swyxio commented Nov 1, 2020

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
Copy link

tgf9 commented Jan 16, 2023

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
Copy link
Owner Author

swyxio commented Jan 18, 2023

hmm maybe you can use stopimmediatepropagation? https://javascript.info/bubbling-and-capturing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants