Longpress
Detects when a pointer is held down for a specified duration and triggers a callback. Useful for contextual actions or alternative interactions.
Usage
<script>
import { longpress } from 'svxui';
</script>
<button
{@attach longpress({
// Enable/disable longpress
enabled: true,
// Custom delay before trigger longpress
delay: 800,
// Handle longpress start event
onLongpressStart: () => console.log('Longpress start'),
// Handle longpress end event
onLongpressEnd: () => console.log('Longpress end')
})}
>
longpress me
</button>API Reference
LongpressOptions
| Property | Type | Default | Description |
|---|---|---|---|
onLongpressStart | function | Called when longpress starts (after delay) | |
onLongpressEnd | function | Called when longpress is released | |
enabled | boolean | true | Enable/disable longpress |
delay | number | 800 | Time in milliseconds before start longpress |