v-touch

Directive

Attaches touch event listeners (touchstart, touchend, touchmove) and recognises swipe gestures (left, right, up, down). All handlers are optional; only attach what you need.

API

Valeur / Arguments

Forme de la valeur du binding et de chaque propriété de l'objet d'options.

start / end / move
(e: { originalEvent: TouchEvent } & ITouchData) => void
Raw touch lifecycle handlers. The event is augmented with ITouchData (coordinates, delta, velocity, direction).
left / right / up / down
(e: ITouchData) => void
Swipe direction handlers. Fired when the touchend velocity and displacement exceed the detection threshold.
parent
boolean
When true, listeners are attached to the parentElement instead of the element itself. Useful for scrollable containers where the element may be smaller than the gesture area.
options
AddEventListenerOptions
Options forwarded to addEventListener (e.g. { passive: true } to improve scroll performance).

The swipe threshold (minimum displacement and velocity) is not currently configurable per-instance. Adjust at the DS level if needed.

Usage

Exemples

Extraits de code prêts à coller dans vos templates.

Swipe left / right

vue

Raw touch lifecycle

vue