### Vue 3 Drag and Drop Events with vue3-touch-events
Source: https://context7.com/robinrodricks/vue3-touch-events/llms.txt
Handles drag operations with continuous tracking for drag start, move, and release events. This example demonstrates basic drag functionality, a 'drag once' event, and dragging elements outside their boundaries. It requires the vue3-touch-events library.
```vue
Drag me around
X: {{ position.x }}, Y: {{ position.y }}
Drag.once event
Drag started!
Can drag outside bounds
Dragging...
```
--------------------------------
### Building Vue 3 Touch Events from Source
Source: https://github.com/robinrodricks/vue3-touch-events/blob/master/README.md
Instructions for building the Vue 3 Touch Events project from its source code. It requires `bun` for installation and building.
```bash
bun install
bun run build
```
--------------------------------
### Plugin Installation and Configuration
Source: https://context7.com/robinrodricks/vue3-touch-events/llms.txt
Register the vue3-touch-events plugin globally with your Vue 3 application and configure options such as event tolerances, frequencies, and CSS classes for consistent touch interactions.
```APIDOC
## Plugin Installation and Configuration
### Description
Register the plugin with your Vue 3 application and configure global settings for all touch events. The installation includes options for customizing thresholds, frequencies, and behavior for various touch gestures.
### Method
Plugin Installation
### Endpoint
app.use(Vue3TouchEvents, options)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **disableClick** (boolean) - Optional - Enable/disable desktop mouse events (default: false)
- **touchClass** (string) - Optional - CSS class applied during touch/hover (default: 'active')
- **namespace** (string) - Optional - Directive namespace (default: 'touch')
- **tapTolerance** (number) - Optional - Pixels of movement allowed for tap (default: 10)
- **touchHoldTolerance** (number) - Optional - Milliseconds to trigger hold event (default: 400)
- **longTapTimeInterval** (number) - Optional - Milliseconds to trigger longtap (default: 400)
- **rollOverFrequency** (number) - Optional - Milliseconds between rollover events (default: 100)
- **dragFrequency** (number) - Optional - Milliseconds between drag events (default: 10)
- **dragOutside** (boolean) - Optional - Fire drag events when dragged outside element (default: false)
- **swipeTolerance** (number) - Optional - Pixels required to trigger swipe (default: 100)
- **swipeConeSize** (number) - Optional - Swipe cone width, 0-1 (default: 0.75)
- **zoomFrequency** (number) - Optional - Milliseconds between zoom events (default: 10)
- **zoomDistance** (number) - Optional - Pixels to trigger zoom event (default: 10)
- **zoomInOutDistance** (number) - Optional - Pixels to trigger zoom.in/out (default: 100)
### Request Example
```typescript
import { createApp } from 'vue';
import Vue3TouchEvents from 'vue3-touch-events';
import App from './App.vue';
const app = createApp(App);
app.use(Vue3TouchEvents, {
disableClick: false,
touchClass: 'active',
namespace: 'touch',
tapTolerance: 10,
touchHoldTolerance: 400,
longTapTimeInterval: 400,
rollOverFrequency: 100,
dragFrequency: 10,
dragOutside: false,
swipeTolerance: 100,
swipeConeSize: 0.75,
zoomFrequency: 10,
zoomDistance: 10,
zoomInOutDistance: 100
});
app.mount('#app');
```
### Response
#### Success Response (Installation Complete)
No specific response; plugin is registered and available in components.
#### Response Example
Plugin registered successfully.
### Error Handling
Ensure Vue 3.x is used; invalid options may cause configuration ignoring.
```
--------------------------------
### Install and Configure vue3-touch-events Plugin
Source: https://context7.com/robinrodricks/vue3-touch-events/llms.txt
Demonstrates how to install the vue3-touch-events plugin globally in a Vue 3 application and configure its core settings. This includes options for disabling click events, applying touch classes, setting namespaces, and customizing tolerances for tap, hold, drag, swipe, and zoom gestures. The configuration aims to provide a unified and flexible touch interaction experience.
```typescript
import { createApp } from 'vue';
import Vue3TouchEvents, { type Vue3TouchEventsOptions } from 'vue3-touch-events';
import App from './App.vue';
const app = createApp(App);
// Install with global configuration
app.use(Vue3TouchEvents, {
// Core settings
disableClick: false, // Enable/disable desktop mouse events
touchClass: 'active', // CSS class applied during touch/hover
namespace: 'touch', // Directive namespace (v-touch, v-touch-class, etc)
// Tap/Click settings
tapTolerance: 10, // Pixels of movement allowed for tap (default: 10px)
touchHoldTolerance: 400, // Milliseconds to trigger hold event (default: 400ms)
longTapTimeInterval: 400, // Milliseconds to trigger longtap (default: 400ms)
rollOverFrequency: 100, // Milliseconds between rollover events (default: 100ms)
// Drag settings
dragFrequency: 10, // Milliseconds between drag events (default: 10ms)
dragOutside: false, // Fire drag events when dragged outside element
// Swipe settings
swipeTolerance: 100, // Pixels required to trigger swipe (default: 100px)
swipeConeSize: 0.75, // Swipe cone width, 0-1 (default: 0.75)
// Zoom settings (mobile only)
zoomFrequency: 10, // Milliseconds between zoom events (default: 10ms)
zoomDistance: 10, // Pixels to trigger zoom event (default: 10px)
zoomInOutDistance: 100 // Pixels to trigger zoom.in/out (default: 100px)
});
app.mount('#app');
```
--------------------------------
### Nuxt 3 Swipe Navigation Example
Source: https://context7.com/robinrodricks/vue3-touch-events/llms.txt
This example shows how to use the v-touch:swipe directive for swipe navigation between slides in a Nuxt 3 component. It demonstrates handling swipe events to update the current slide index.
```vue
...
```
--------------------------------
### v-touch-class Directive Example
Source: https://github.com/robinrodricks/vue3-touch-events/blob/master/README.md
Example of using the v-touch-class directive to dynamically add a CSS class ('active') to an element when it is tapped or hovered over. This replaces the need for :active and :hover pseudo-classes.
```html
Tap Me
```
--------------------------------
### Nuxt 3 Interactive Menu with Tap Events
Source: https://context7.com/robinrodricks/vue3-touch-events/llms.txt
This example demonstrates using the v-touch:tap directive to handle tap events on menu items in a Nuxt 3 component. It shows how to navigate to different pages based on the tapped menu item.
```vue
...
```
--------------------------------
### Nuxt 3 Long Press Action Example
Source: https://context7.com/robinrodricks/vue3-touch-events/llms.txt
This example demonstrates using the v-touch:longtap directive to trigger an action on a long press of a button in a Nuxt 3 component. It shows how to customize the long tap time interval using v-touch-options.
```vue