@marsio/vue-draggable 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/README.md +143 -3
  2. package/build/cjs/Draggable.js +328 -70
  3. package/build/cjs/DraggableCore.js +884 -74
  4. package/build/cjs/utils/domFns.js +60 -18
  5. package/build/cjs/utils/noop.js +9 -0
  6. package/build/cjs/utils/positionFns.js +78 -40
  7. package/build/cjs/utils/shims.js +2 -2
  8. package/build/web/vue-draggable.min.179e4c366756eb300fbf.hot-update.js +30 -0
  9. package/build/web/vue-draggable.min.19bbf2e057882622f2f8.hot-update.js +30 -0
  10. package/build/web/vue-draggable.min.6cc5294fa16ef72f1dc6.hot-update.js +30 -0
  11. package/build/web/vue-draggable.min.870ce0c3b8d1e5af7abb.hot-update.js +30 -0
  12. package/build/web/vue-draggable.min.8a0eb1cdda0c757918ec.hot-update.js +30 -0
  13. package/build/web/vue-draggable.min.8c4367bbfb0323ed907d.hot-update.js +30 -0
  14. package/build/web/vue-draggable.min.900bc4aa354497b18d12.hot-update.js +30 -0
  15. package/build/web/vue-draggable.min.a529009727f3ce56b642.hot-update.js +30 -0
  16. package/build/web/vue-draggable.min.js +241 -282
  17. package/build/web/vue-draggable_min.179e4c366756eb300fbf.hot-update.json +1 -0
  18. package/build/web/vue-draggable_min.19bbf2e057882622f2f8.hot-update.json +1 -0
  19. package/build/web/vue-draggable_min.6cc5294fa16ef72f1dc6.hot-update.json +1 -0
  20. package/build/web/vue-draggable_min.870ce0c3b8d1e5af7abb.hot-update.json +1 -0
  21. package/build/web/vue-draggable_min.8a0eb1cdda0c757918ec.hot-update.json +1 -0
  22. package/build/web/vue-draggable_min.8c4367bbfb0323ed907d.hot-update.json +1 -0
  23. package/build/web/vue-draggable_min.900bc4aa354497b18d12.hot-update.json +1 -0
  24. package/build/web/vue-draggable_min.a529009727f3ce56b642.hot-update.json +1 -0
  25. package/package.json +4 -3
  26. package/typings/index.d.ts +80 -47
package/README.md CHANGED
@@ -6,7 +6,7 @@ Draggable and DraggableCore are **Vue3** components designed to make elements dr
6
6
  <img src="https://user-images.githubusercontent.com/6365230/95649276-f3a02480-0b06-11eb-8504-e0614a780ba4.gif" />
7
7
  </p>
8
8
 
9
- [**[Demo](http://110.41.33.162:9001/) | [Changelog](/CHANGELOG.md) | [View Example](/example/example.js)**]
9
+ [**[Demo](https://marsio.top/vue-draggable/) | [Changelog](/CHANGELOG.md) | [View Example](/example/example.js) | [MCP Server](./mcp/README.md)**]
10
10
 
11
11
  ## ✨ Features
12
12
  - **Compatibility**: Compatible with server-rendered apps, PC, and mobile devices.
@@ -17,7 +17,62 @@ Draggable and DraggableCore are **Vue3** components designed to make elements dr
17
17
  - **Position Offset**: Supports an offset for the draggable position (`positionOffset`), enabling adjustments to the element's position without altering its actual position properties.
18
18
  - **Grid Snapping**: Allows the draggable element to snap to a grid (`grid` prop), facilitating alignment and precise placement during dragging.
19
19
  - **Accessibility and Interaction**: Includes props for disabling the draggable functionality (`disabled`), allowing any mouse button to initiate dragging (`allowAnyClick`), and enabling a hack to prevent text selection during drag (`enableUserSelectHack`), enhancing usability and accessibility.
20
+ ## 🤖 AI IDE Integration (MCP Server)
20
21
 
22
+ **Supercharge your AI-powered development workflow!** Vue-Draggable now includes an official **Model Context Protocol (MCP) Server** that provides your AI assistant with comprehensive, real-time access to all component APIs, props, and examples.
23
+
24
+ ### ✨ What is MCP?
25
+
26
+ The Model Context Protocol enables AI assistants like Claude Desktop, Cursor, and other AI IDEs to access live, accurate documentation and code examples directly from the source. No more outdated docs or hallucinated APIs!
27
+
28
+ ### 🚀 Key Benefits
29
+
30
+ - **🎯 Accurate API Usage**: AI gets real-time access to all props, types, and default values
31
+ - **📚 Contextual Examples**: Intelligent code suggestions based on actual component usage
32
+ - **🔄 Always Up-to-Date**: Documentation syncs automatically with code changes
33
+ - **⚡ Enhanced Productivity**: Write draggable components faster with AI assistance
34
+
35
+ ### 📋 Quick Setup
36
+
37
+ #### For Cursor IDE:
38
+ ```json
39
+ {
40
+ "mcpServers": {
41
+ "vue-draggable": {
42
+ "command": "npx",
43
+ "args": ["@marsio/vue-draggable-mcp"]
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ #### For Claude Desktop:
50
+ Add to your Claude Desktop configuration:
51
+ ```json
52
+ {
53
+ "mcpServers": {
54
+ "vue-draggable": {
55
+ "command": "npx",
56
+ "args": ["@marsio/vue-draggable-mcp"]
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ ### 🛠️ Available Tools
63
+
64
+ - **`get_vue_draggable_docs`**: Complete documentation in Markdown format
65
+ - **`list_vue_draggable_props`**: Structured props information with types and defaults
66
+ - **`get_vue_draggable_type`**: Specific type definitions and interfaces
67
+
68
+ ### 💡 Example AI Prompts
69
+
70
+ After setup, try asking your AI assistant:
71
+ - *"Create a draggable card component with grid snapping"*
72
+ - *"Show me all available props for Draggable component"*
73
+ - *"How do I constrain dragging to horizontal axis only?"*
74
+
75
+ [Learn more about MCP setup →](./mcp/README.md)
21
76
  ## 📦 Quick Start
22
77
 
23
78
  To quickly start using `@marsio/vue-draggable`, follow the steps below:
@@ -98,6 +153,7 @@ A simple component for making elements draggable.
98
153
  #### Technical Documentation
99
154
 
100
155
  - [Installing](#installing)
156
+ - [AI IDE Integration (MCP)](#🤖-ai-ide-integration-mcp-server)
101
157
  - [Exports](#exports)
102
158
  - [Draggable](#draggable)
103
159
  - [Draggable Usage](#draggable-usage)
@@ -204,8 +260,8 @@ type DraggableData = {
204
260
  // If set to `true`, will allow dragging on non left-button clicks.
205
261
  allowAnyClick: boolean,
206
262
 
207
- // Determines which axis the draggable can move. This only affects
208
- // flushing to the DOM. Callbacks will still include all values.
263
+ // Determines which axis the draggable can move.
264
+ // Disabled axis movement is ignored and callbacks will report 0 deltas.
209
265
  // Accepted values:
210
266
  // - `both` allows movement horizontally and vertically (default).
211
267
  // - `x` limits movement to horizontal axis.
@@ -213,6 +269,12 @@ allowAnyClick: boolean,
213
269
  // - 'none' stops all movement.
214
270
  axis: string,
215
271
 
272
+ // If true, lock to the dominant axis after the drag starts (prevents diagonal drift).
273
+ directionLock: boolean,
274
+
275
+ // Distance (px) before directionLock chooses an axis.
276
+ directionLockThreshold: number,
277
+
216
278
  // Specifies movement boundaries. Accepted values:
217
279
  // - `parent` restricts movement within the node's offsetParent
218
280
  // (nearest node with position relative or absolute), or
@@ -227,6 +289,10 @@ bounds: {left?: number, top?: number, right?: number, bottom?: number} | string,
227
289
  // Example: '.body'
228
290
  cancel: string,
229
291
 
292
+ // If true, prevents dragging from starting on common interactive elements
293
+ // (inputs, buttons, links, contenteditable).
294
+ cancelInteractiveElements: boolean,
295
+
230
296
  // Class names for draggable UI.
231
297
  // Default to 'vue-draggable', 'vue-draggable-dragging', and 'vue-draggable-dragged'
232
298
  defaultClassName: string,
@@ -242,6 +308,48 @@ defaultPosition: {x: number, y: number},
242
308
  // If true, will not call any drag handlers.
243
309
  disabled: boolean,
244
310
 
311
+ // If true, do not preventDefault() during touch drags, allowing the page/containers to scroll.
312
+ allowMobileScroll: boolean,
313
+
314
+ // If true, auto-scroll nearest scrollable container (and window) when the pointer is near an edge.
315
+ autoScroll: boolean,
316
+
317
+ // Distance (px) from an edge to start auto-scrolling.
318
+ autoScrollThreshold: number,
319
+
320
+ // Max auto-scroll speed (px per frame).
321
+ autoScrollMaxSpeed: number,
322
+
323
+ // Auto-scroll axis.
324
+ autoScrollAxis: 'both' | 'x' | 'y' | 'none',
325
+
326
+ // If false, never auto-scroll the window.
327
+ autoScrollIncludeWindow: boolean,
328
+
329
+ // Optional: specify which container(s) to auto-scroll.
330
+ // Supports selector string, element, 'window', or an array of those.
331
+ autoScrollContainer: string | HTMLElement | Window | Array<string | HTMLElement | Window> | null,
332
+
333
+ // Minimum distance in pixels before the drag starts.
334
+ // Useful to prevent accidental drags on click/tap.
335
+ dragStartThreshold: number,
336
+
337
+ // Touch-only: delay (ms) before drag can start (long-press activation).
338
+ dragStartDelay: number,
339
+
340
+ // Touch-only: movement tolerance (px) allowed during dragStartDelay before cancelling the drag start.
341
+ dragStartDelayTolerance: number,
342
+
343
+ // If true, suppress the click event fired after a drag.
344
+ enableClickSuppression: boolean,
345
+
346
+ // How long (ms) to suppress the next click after drag stop.
347
+ clickSuppressionDuration: number,
348
+
349
+ // If true, coalesce drag updates to requestAnimationFrame (at most once per frame).
350
+ // This significantly reduces work under high-frequency move events.
351
+ useRafDrag: boolean,
352
+
245
353
  // Specifies the x and y that dragging should snap to.
246
354
  grid: [number, number],
247
355
 
@@ -290,6 +398,24 @@ scale: number
290
398
  Note that sending `class`, `style`, or `transform` as properties will error - set them on the child element
291
399
  directly.
292
400
 
401
+ ## Auto Scroll
402
+
403
+ Enable auto-scroll while dragging near an edge:
404
+
405
+ ```vue
406
+ <Draggable :autoScroll="true" :autoScrollThreshold="40" :autoScrollMaxSpeed="24" />
407
+ ```
408
+
409
+ Scroll only a specific container (and never the window):
410
+
411
+ ```vue
412
+ <Draggable :autoScroll="true" autoScrollContainer=".scroll-pane" :autoScrollIncludeWindow="false" />
413
+ ```
414
+
415
+ ## Pointer Events
416
+
417
+ When supported, `<DraggableCore>` uses Pointer Events (with `setPointerCapture()` for more robust drags outside the element).
418
+ For touch pointers, Pointer Events require `touch-action` to be non-`auto` (e.g. `touch-action: none`); otherwise it falls back to Touch Events.
293
419
 
294
420
  ## Controlled vs. Uncontrolled
295
421
 
@@ -326,7 +452,21 @@ on itself and thus must have callbacks attached to be useful.
326
452
  allowAnyClick: boolean,
327
453
  cancel: string,
328
454
  disabled: boolean,
455
+ allowMobileScroll: boolean,
456
+ autoScroll: boolean,
457
+ autoScrollThreshold: number,
458
+ autoScrollMaxSpeed: number,
459
+ autoScrollAxis: 'both' | 'x' | 'y' | 'none',
460
+ autoScrollIncludeWindow: boolean,
461
+ autoScrollContainer: string | HTMLElement | Window | Array<string | HTMLElement | Window> | null,
462
+ cancelInteractiveElements: boolean,
463
+ enableClickSuppression: boolean,
464
+ clickSuppressionDuration: number,
465
+ dragStartDelay: number,
466
+ dragStartDelayTolerance: number,
329
467
  enableUserSelectHack: boolean,
468
+ dragStartThreshold: number,
469
+ useRafDrag: boolean,
330
470
  offsetParent: HTMLElement,
331
471
  grid: [number, number],
332
472
  handle: string,