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
Value / Arguments
Shape of the binding value and each property in the options object.
- 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.
- parentboolean
- 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.
- optionsAddEventListenerOptions
- 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
Examples
Ready-to-paste code snippets for your templates.
Swipe left / right
Raw touch lifecycle