{"id":32983031,"url":"https://github.com/zhanziyang/v-dragged","last_synced_at":"2026-02-03T11:20:01.088Z","repository":{"id":57389636,"uuid":"106284062","full_name":"zhanziyang/v-dragged","owner":"zhanziyang","description":"Vue directive plugin for drag event detection.","archived":false,"fork":false,"pushed_at":"2018-11-17T14:54:29.000Z","size":275,"stargazers_count":90,"open_issues_count":4,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-22T03:53:23.206Z","etag":null,"topics":["directive","drag","event","vue","vue-plugin"],"latest_commit_sha":null,"homepage":"https://zhanziyang.github.io/v-dragged/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhanziyang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-09T12:59:59.000Z","updated_at":"2025-01-03T12:55:33.000Z","dependencies_parsed_at":"2022-09-15T05:01:50.773Z","dependency_job_id":null,"html_url":"https://github.com/zhanziyang/v-dragged","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zhanziyang/v-dragged","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanziyang%2Fv-dragged","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanziyang%2Fv-dragged/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanziyang%2Fv-dragged/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanziyang%2Fv-dragged/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhanziyang","download_url":"https://codeload.github.com/zhanziyang/v-dragged/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhanziyang%2Fv-dragged/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29044106,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T10:09:22.136Z","status":"ssl_error","status_checked_at":"2026-02-03T10:09:16.814Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["directive","drag","event","vue","vue-plugin"],"created_at":"2025-11-13T07:00:32.996Z","updated_at":"2026-02-03T11:20:01.083Z","avatar_url":"https://github.com/zhanziyang.png","language":"JavaScript","funding_links":[],"categories":["UI Utilities [🔝](#readme)","UI实用程序","Components \u0026 Libraries","UI Utilities"],"sub_categories":["事件处理","UI Utilities","Event Handling"],"readme":"# v-dragged\n\u003e Vue directive plugin for drag event detection.\n\n**NOTE:** This directive listens for mouse/touch events, and sets a handler for when a drag action is detected. This is different from setting `draggable` on element, in that you need to move the element yourself according to the information *`v-dragged`* provides.\n\n\n## Install\n\n```bash\nnpm install --save v-dragged\n```\n```js\nimport Vue from 'vue'\nimport VDragged from 'v-dragged'\n\nVue.use(VDragged) \n```\n\n## Example\n\nIn your component:\n\n```html\n\u003cdiv v-dragged=\"onDragged\"\u003e\u003c/div\u003e\n```\n```js\n{\n  // ...other options omitted\n\n  methods: {\n    onDragged({ el, deltaX, deltaY, offsetX, offsetY, clientX, clientY, first, last }) {\n      if (first) {\n        this.isDragging = true\n        return\n      }\n      if (last) {\n        this.isDragging = false\n        return\n      }\n      var l = +window.getComputedStyle(el)['left'].slice(0, -2) || 0\n      var t = +window.getComputedStyle(el)['top'].slice(0, -2) || 0\n      el.style.left = l + deltaX + 'px'\n      el.style.top = t + deltaY + 'px'\n    }\n  }\n}\n```\n\n### Event Details\n\nThe argument passed to the event handler is an object containing the following properties:\n\n#### `el`\n- The target element on which the directive binds.\n- type: HTMLElement\n\n#### `first`\n- A boolean to indicate whether it is the first move of the drag. (drag starts here).\n- type: Boolean\n\n#### `last`\n- A boolean to indicate whether it is the last move of the drag. (drag ends here).\n- type: Boolean\n\n#### `deltaX`\n- The change of the pointer (mouse/touch)'s **x** coordinate from the last position.\u003cbr\u003e\n  It is `undefined` when `first` or `last` is `true`.\n- type: Number\n\n#### `deltaY`\n- The change of the pointer (mouse/touch)'s **y** coordinate from the last position.\u003cbr\u003e\n  It is `undefined` when `first` or `last` is `true`.\n- type: Number\n\n#### `offsetX`\n- The change of the pointer (mouse/touch)'s **x** coordinate from **the starting position**.\u003cbr\u003e\n  It is `undefined` when `first` or `last` is `true`.\n- type: Number\n\n#### `offsetY`\n- The change of the pointer (mouse/touch)'s **y** coordinate from **the starting position**.\u003cbr\u003e\n  It is `undefined` when `first` or `last` is `true`.\n- type: Number\n\n#### `clientX`\n- Current **x** coordinate of the pointer (mouse/touch).\n- type: Number\n\n#### `clientY`\n- Current **y** coordinate of the pointer (mouse/touch).\n- type: Number\n\n\n## Modifier\n\n#### `prevent`\n- prevent default events on pointer events (`touchstart`, `touchmove`, `touchend`, `mousedown`, `mousemove`, `mouseup`).\n\n```html\n\u003cdiv v-dragged.prevent=\"onDragged\"\u003e\u003c/div\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhanziyang%2Fv-dragged","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhanziyang%2Fv-dragged","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhanziyang%2Fv-dragged/lists"}