[ @sdxc/ui/mixins ]
longPress
Generic long-press detection for any host element.
import { longPress } from "@sdxc/ui/mixins";Usage
Detects a long press on any host element: a primary-pointer pointerdown
starts a timer, tracking only one press at a time, and dispatches
LongPressEvent once the pointer holds still for the full duration.
Signature
longPress(options?: LongPress.Options): MixinDescriptor<HTMLElement>Returns a mixin descriptor for a host element's mix prop.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | LongPress.Options | Duration configuration; see LongPress.Options. Reset to an empty object when the mixin runtime passes its trailing current-props argument in its place. |
Examples
<li
id="row-1"
mix={[
longPress(),
on("ui:long-press", (event) => {
let menu = document.getElementById("row-1-menu");
if (!menu) return;
anchor(menu, event.point);
menu.showPopover();
}),
]}
>
Row 1
</li>
<div id="row-1-menu" popover="auto" role="menu">...</div>Used with it
The events, constants and types its module publishes, each imported from @sdxc/ui/mixins too.
Event
LongPressEvent
Dispatched on a host by longPress once a pointer press has held
its position for the configured duration, carrying that position as an
AnchorPoint so a consumer can anchor a menu, tooltip, or preview to it.
new LongPressEvent(point: AnchorPoint)| Property | Type | Description |
|---|---|---|
point | readonly AnchorPoint | Pointer position the press held, in viewport coordinates, ready to pass straight into @remix-run/ui/anchor's point-based anchoring. |
Interface
LongPress.Options
Configuration accepted by longPress.
| Member | Type | Description |
|---|---|---|
duration? | number | Milliseconds the pointer must remain pressed, without drifting past the movement tolerance, before LongPressEvent fires. Defaults to 500. |