Touch
Touch protocol schemas
Touch Target Configuration Schema
Ensures touch targets meet WCAG 2.5.5 minimum size requirements (44x44px).
Source: packages/spec/src/ui/touch.zod.ts
TypeScript Usage
import { GestureConfig, GestureType, LongPressGestureConfig, PinchGestureConfig, SwipeDirection, SwipeGestureConfig, TouchInteraction, TouchTargetConfig } from '@objectstack/spec/ui';
import type { GestureConfig, GestureType, LongPressGestureConfig, PinchGestureConfig, SwipeDirection, SwipeGestureConfig, TouchInteraction, TouchTargetConfig } from '@objectstack/spec/ui';
// Validate data
const result = GestureConfig.parse(data);GestureConfig
Per-gesture configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| type | Enum<'swipe' | 'pinch' | 'long_press' | 'double_tap' | 'drag' | 'rotate' | 'pan'> | ✅ | Gesture type to configure |
| label | string | Object | optional | Descriptive label for the gesture action |
| enabled | boolean | ✅ | Whether this gesture is active |
| swipe | Object | optional | Swipe gesture settings (when type is swipe) |
| pinch | Object | optional | Pinch gesture settings (when type is pinch) |
| longPress | Object | optional | Long press settings (when type is long_press) |
GestureType
Touch gesture type
Allowed Values
swipepinchlong_pressdouble_tapdragrotatepan
LongPressGestureConfig
Long press gesture recognition settings
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| duration | number | ✅ | Hold duration in milliseconds to trigger long press |
| moveTolerance | number | optional | Max movement in pixels allowed during press |
PinchGestureConfig
Pinch/zoom gesture recognition settings
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| minScale | number | optional | Minimum scale factor (e.g., 0.5 for 50%) |
| maxScale | number | optional | Maximum scale factor (e.g., 3.0 for 300%) |
SwipeDirection
Allowed Values
updownleftright
SwipeGestureConfig
Swipe gesture recognition settings
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| direction | Enum<'up' | 'down' | 'left' | 'right'>[] | ✅ | Allowed swipe directions |
| threshold | number | optional | Minimum distance in pixels to recognize swipe |
| velocity | number | optional | Minimum velocity (px/ms) to trigger swipe |
TouchInteraction
Touch and gesture interaction configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| gestures | Object[] | optional | Configured gesture recognizers |
| touchTarget | Object | optional | Touch target sizing and hit area |
| hapticFeedback | boolean | optional | Enable haptic feedback on touch interactions |
| ariaLabel | string | Object | optional | Accessible label for screen readers (WAI-ARIA aria-label) |
| ariaDescribedBy | string | optional | ID of element providing additional description (WAI-ARIA aria-describedby) |
| role | string | optional | WAI-ARIA role attribute (e.g., "dialog", "navigation", "alert") |
TouchTargetConfig
Touch target sizing configuration (WCAG accessible)
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| minWidth | number | ✅ | Minimum touch target width in pixels (WCAG 2.5.5: 44px) |
| minHeight | number | ✅ | Minimum touch target height in pixels (WCAG 2.5.5: 44px) |
| padding | number | optional | Additional padding around touch target in pixels |
| hitSlop | Object | optional | Invisible hit area extension beyond the visible bounds |