Parameters
API reference for Vue Table Touch Scroll
API Reference
Directive
vTableTouchScroll
A Vue 3 custom directive that adds touch scroll support to table elements.
Global Registration:
Local Import:
Type Definitions
TableTouchScrollOptions
Configuration options interface for the directive.
| Property | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Whether to enable touch scrolling |
preset | TablePreset | - | UI library preset name, automatically applies the corresponding scroll container selector |
selector | string | - | CSS selector for the target scroll element, takes priority over preset |
friction | number | 0.95 | Friction/decay rate. Higher = slower decay (smoother scrolling), lower = faster stop (range: 0.8 - 0.99) |
dragThreshold | number | 5 | Displacement threshold (px) before determining scroll direction, distinguishes minor jitter from intentional dragging |
disableInertia | boolean | false | Whether to disable inertia scrolling. When true, scrolling stops immediately on finger release |
clickBlockThreshold | number | 0.5 | Speed threshold (px/ms) for emergency stop click blocking. Higher = more lenient, lower = more strict (range: 0.3 - 1.0) |
onScrollStart | () => void | - | Callback fired when scrolling starts, after finger displacement exceeds dragThreshold and direction is locked |
onScrollEnd | () => void | - | Callback fired when scrolling ends, after inertia animation fully stops |
Scroll container priority: selector > preset > the directive's bound element.
Full Type Signature:
TablePreset
Supported UI library preset types and their corresponding scroll container selectors.
| Preset | UI Library | Selector |
|---|---|---|
'element-plus' | Element Plus | .el-scrollbar__wrap |
'ant-design-vue' | Ant Design Vue | .ant-table-body |
'arco-design' | Arco Design | .arco-table-body |
'naive-ui' | Naive UI | .n-scrollbar-container |
'primevue' | PrimeVue | .p-datatable-table-container |
'vuetify' | Vuetify | .v-table__wrapper tbody |
'vxe-table' | VxeTable | .vxe-table--body-inner-wrapper |
Exports
UI_LIBRARY_SELECTORS
UI library selector preset mapping constant.
getSelectorByPreset
Get the corresponding CSS selector by preset name.
Parameters
| Parameter | Type | Description |
|---|---|---|
preset | TablePreset | UI library preset name |
Returns
string | undefined — The corresponding CSS selector, or undefined if the preset does not exist.
Internal Physics Engine Parameters
Physics engine constants used internally by the directive (not externally configurable):
| Constant | Value | Description |
|---|---|---|
DEFAULT_FRICTION | 0.95 | Default friction/decay rate |
MIN_VELOCITY | 0.05 | Velocity threshold (px/ms) to stop inertia animation |
MAX_DT | 32 | Max frame interval limit (ms), prevents jumps after frame drops |
DEFAULT_DRAG_THRESHOLD | 5 | Default drag detection threshold (px) |
INERTIA_STOP_DELAY | 80 | Inertia protection delay (ms). If finger pauses longer than this before release, inertia is not triggered |
SAFE_CLICK_VELOCITY | 0.5 | Default speed threshold (px/ms) for emergency stop click blocking |