{"id":13432602,"url":"https://github.com/desandro/draggabilly","last_synced_at":"2025-10-03T21:48:53.424Z","repository":{"id":6577916,"uuid":"7820076","full_name":"desandro/draggabilly","owner":"desandro","description":":point_down: Make that shiz draggable","archived":false,"fork":false,"pushed_at":"2022-03-31T13:17:01.000Z","size":515,"stargazers_count":3874,"open_issues_count":18,"forks_count":384,"subscribers_count":92,"default_branch":"master","last_synced_at":"2025-09-23T20:41:38.908Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://draggabilly.desandro.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/desandro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-25T12:50:57.000Z","updated_at":"2025-09-17T06:01:45.000Z","dependencies_parsed_at":"2022-09-11T02:10:10.233Z","dependency_job_id":null,"html_url":"https://github.com/desandro/draggabilly","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/desandro/draggabilly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desandro%2Fdraggabilly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desandro%2Fdraggabilly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desandro%2Fdraggabilly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desandro%2Fdraggabilly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/desandro","download_url":"https://codeload.github.com/desandro/draggabilly/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desandro%2Fdraggabilly/sbom","scorecard":{"id":335917,"data":{"date":"2025-08-11","repo":{"name":"github.com/desandro/draggabilly","commit":"125258c6f59f0069cd2a50f29e7358de390ccbb8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.1,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/desandro/draggabilly/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/desandro/draggabilly/nodejs.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":4,"reason":"6 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T04:42:27.464Z","repository_id":6577916,"created_at":"2025-08-18T04:42:27.465Z","updated_at":"2025-08-18T04:42:27.465Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276817012,"owners_count":25709949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-24T02:00:09.776Z","response_time":97,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-07-31T02:01:14.007Z","updated_at":"2025-10-03T21:48:53.396Z","avatar_url":"https://github.com/desandro.png","language":"JavaScript","readme":"# Draggabilly\n\n\u003cp class=\"tagline\"\u003eMake that shiz draggable\u003c/p\u003e\n\n[draggabilly.desandro.com](https://draggabilly.desandro.com)\n\nRad because it supports mouse and touch devices.\n\nDraggabilly v3.0.0\n\n## Install\n\n### Download\n\n+ [draggabilly.pkgd.min.js](https://unpkg.com/draggabilly@3/dist/draggabilly.pkgd.min.js) minified\n+ [draggabilly.pkgd.js](https://unpkg.com/draggabilly@3/dist/draggabilly.pkgd.js) un-minified\n\n### Package managers\n\nInstall with npm: `npm install draggabilly`\n\nInstall with Yarn: `yarn add draggabilly`\n\n### CDN\n\nLink directly to `draggabilly.pkgd.min.js` on [unpkg.com](https://unpkg.com).\n\n``` html\n\u003cscript src=\"https://unpkg.com/draggabilly@3/dist/draggabilly.pkgd.min.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nInitialize Draggabilly as a jQuery plugin\n\n``` js\nvar $draggable = $('.draggable').draggabilly({\n  // options...\n})\n```\n\nInitialize Draggabilly with vanilla JS\n\n``` js\nvar elem = document.querySelector('.draggable');\nvar draggie = new Draggabilly( elem, {\n  // options...\n});\n\n// or pass in selector string as first argument\nvar draggie = new Draggabilly( '.draggable', {\n  // options...\n});\n\n// if you have multiple .draggable elements\n// get all draggie elements\nvar draggableElems = document.querySelectorAll('.draggable');\n// array of Draggabillies\nvar draggies = []\n// init Draggabillies\nfor ( var i=0; i \u003c draggableElems.length; i++ ) {\n  var draggableElem = draggableElems[i];\n  var draggie = new Draggabilly( draggableElem, {\n    // options...\n  });\n  draggies.push( draggie );\n}\n```\n\n### Classes\n\n+ `.is-pointer-down` added when the user's pointer (mouse, touch, pointer) first presses down.\n+ `.is-dragging` added when elements starts to drag.\n\n## Options\n\n### axis\n\n**Type:** _String_\n\n**Values:** `'x'` or `'y'`\n\n``` js\naxis: 'x'\n```\n\nConstrains movement to horizontal or vertical axis.\n\n### containment\n\n**Type:** _Element_, Selector _String_, or _Boolean_\n\n``` js\ncontainment: '.container'\n```\n\nContains movement to the bounds of the element. If `true`, the container will be the parent element.\n\n### grid\n\n**Type:** _Array_\n\n**Values:** `[ x, y ]`\n\n``` js\ngrid: [ 20, 20 ]\n```\n\nSnaps the element to a grid, every x and y pixels.\n\n### handle\n\n**Type:** Selector _String_, _Array_, _HTMLElement_\n\n``` js\n// select all .handle children with selector string\nhandle: '.handle'\n\n// set as element\nhandle: element.querySelector('.handle')\n\n// set as array or NodeList\nhandle: [ element.querySelector('.handle1'), element.querySelector('.handle2') ]\n```\n\nSpecifies on what element the drag interaction starts.\n\n`handle` is useful for when you do not want all inner elements to be used for dragging, like inputs and forms. See [back handle example on CodePen](https://codepen.io/desandro/pen/znAuH).\n\n## Events\n\nBind events with jQuery with standard jQuery event methods `.on()`, `.off()`, and `.one()`. Inside jQuery event listeners `this` refers to the Draggabilly element.\n\n``` js\n// jQuery\nfunction listener(/* parameters */) {\n  // get Draggabilly instance\n  var draggie = $(this).data('draggabilly');\n  console.log( 'eventName happened', draggie.position.x, draggie.position.y );\n}\n// bind event listener\n$draggable.on( 'eventName', listener );\n// unbind event listener\n$draggable.off( 'eventName', listener );\n// bind event listener to trigger once. note ONE not ON\n$draggable.one( 'eventName', function() {\n  console.log('eventName happened just once');\n});\n```\n\nBind events with vanilla JS with `.on()`, `.off()`, and `.once()` methods. Inside vanilla JS event listeners `this` refers to the Draggabilly instance.\n\n``` js\n// vanilla JS\nfunction listener(/* parameters */) {\n  console.log( 'eventName happened', this.position.x, this.position.y );\n}\n// bind event listener\ndraggie.on( 'eventName', listener );\n// unbind event listener\ndraggie.off( 'eventName', listener );\n// bind event listener to trigger once. note ONCE not ONE or ON\ndraggie.once( 'eventName', function() {\n  console.log('eventName happened just once');\n});\n```\n\n### dragStart\n\nTriggered when dragging starts and the element starts moving. Dragging starts after the user's pointer has moved a couple pixels to allow for clicks.\n\n```js\n// jQuery\n$draggable.on( 'dragStart', function( event, pointer ) {...})\n// vanilla JS\ndraggie.on( 'dragStart', function( event, pointer ) {...})\n```\n\n+ `event` - **Type:** _Event_ - the original `mousedown` or `touchstart` event\n+ `pointer` - **Type:** _MouseEvent_ or _Touch_ - the event object that has `.pageX` and `.pageY`\n\n### dragMove\n\nTriggered when dragging moves.\n\n```js\n// jQuery\n$draggable.on( 'dragMove', function( event, pointer, moveVector ) {...})\n// vanilla JS\ndraggie.on( 'dragMove', function( event, pointer, moveVector ) {...})\n```\n\n+ `event` - **Type:** _Event_ - the original `mousemove` or `touchmove` event\n+ `pointer` - **Type:** _MouseEvent_ or _Touch_ - the event object that has `.pageX` and `.pageY`\n+ `moveVector` **Type:** _Object_ - How far the pointer has moved from its start position `{ x: 20, y: -30 }`\n\n### dragEnd\n\nTriggered when dragging ends.\n\n```js\n// jQuery\n$draggable.on( 'dragEnd', function( event, pointer ) {...})\n// vanilla JS\ndraggie.on( 'dragEnd', function( event, pointer ) {...})\n```\n\n+ `event` - **Type:** _Event_ - the original `mouseup` or `touchend` event\n+ `pointer` - **Type:** _MouseEvent_ or _Touch_ - the event object that has `.pageX` and `.pageY`\n\n### pointerDown\n\nTriggered when the user's pointer (mouse, touch, pointer) presses down.\n\n```js\n// jQuery\n$draggable.on( 'pointerDown', function( event, pointer ) {...})\n// vanilla JS\ndraggie.on( 'pointerDown', function( event, pointer ) {...})\n```\n\n+ `event` - **Type:** _Event_ - the original `mousedown` or `touchstart` event\n+ `pointer` - **Type:** _MouseEvent_ or _Touch_ - the event object that has `.pageX` and `.pageY`\n\n### pointerMove\n\nTriggered when the user's pointer moves.\n\n```js\n// jQuery\n$draggable.on( 'pointerMove', function( event, pointer, moveVector ) {...})\n// vanilla JS\ndraggie.on( 'pointerMove', function( event, pointer, moveVector ) {...})\n```\n\n+ `event` - **Type:** _Event_ - the original `mousemove` or `touchmove` event\n+ `pointer` - **Type:** _MouseEvent_ or _Touch_ - the event object that has `.pageX` and `.pageY`\n+ `moveVector` **Type:** _Object_ - How far the pointer has moved from its start position `{ x: 20, y: -30 }`\n\n### pointerUp\n\nTriggered when the user's pointer unpresses.\n\n```js\n// jQuery\n$draggable.on( 'pointerUp', function( event, pointer ) {...})\n// vanilla JS\ndraggie.on( 'pointerUp', function( event, pointer ) {...})\n```\n\n+ `event` - **Type:** _Event_ - the original `mouseup` or `touchend` event\n+ `pointer` - **Type:** _MouseEvent_ or _Touch_ - the event object that has `.pageX` and `.pageY`\n\n### staticClick\n\nTriggered when the user's pointer is pressed and unpressed and has not moved enough to start dragging.\n\n`click` events are hard to detect with draggable UI, as they are triggered whenever a user drags. Draggabilly's staticClick event resolves this, as it is triggered when the user has not dragged.\n\n```js\n// jQuery\n$draggable.on( 'staticClick', function( event, pointer ) {...})\n// vanilla JS\ndraggie.on( 'staticClick', function( event, pointer ) {...})\n```\n\n+ `event` - **Type:** _Event_ - the original `mouseup` or `touchend` event\n+ `pointer` - **Type:** _MouseEvent_ or _Touch_ - the event object that has `.pageX` and `.pageY`\n\n## Methods\n\n### disable\n\n``` js\n// jQuery\n$draggable.draggabilly('disable')\n// vanilla JS\ndraggie.disable()\n```\n\n### enable\n\n``` js\n// jQuery\n$draggable.draggabilly('enable')\n// vanilla JS\ndraggie.enable()\n```\n\n### setPosition\n\n``` js\n// jQuery\n$draggable.draggabilly( 'setPosition', x, y )\n// vanilla JS\ndraggie.setPosition( x, y )\n```\n\n+ `x` - **Type:** _Number_ - horizontal position\n+ `y` - **Type:** _Number_ - vertical position\n\n### dragEnd\n\nStop dragging.\n\n``` js\n// jQuery\n$draggable.draggabilly('dragEnd')\n// vanilla JS\ndraggie.dragEnd()\n```\n\n### destroy\n\n``` js\n// jQuery\n$draggable.draggabilly('destroy')\n// vanilla JS\ndraggie.destroy()\n```\n\n### jQuery.fn.data('draggabilly')\n\nGet the Draggabilly instance from a jQuery object. Draggabilly instances are useful to access Draggabilly properties.\n\n``` js\nvar draggie = $('.draggable').data('draggabilly')\n// access Draggabilly properties\nconsole.log( 'draggie at ' + draggie.position.x + ', ' + draggie.position.y )\n```\n\n## Properties\n\n### position\n\n``` js\ndraggie.position\n// =\u003e { x: 20, y: -30 }\n```\n\n+ `position` - **Type:** _Object_\n+ `x` - **Type:** _Number_\n+ `y` - **Type:** _Number_\n\n## Webpack \u0026 Browserify\n\nInstall [Draggabilly with npm](https://www.npmjs.com/package/draggabilly).\n\n```\nnpm install draggabilly\n```\n\n``` js\nvar Draggabilly = require('draggabilly');\n\nvar draggie = new Draggabilly( '.draggable', {\n  // options\n});\n```\n\nTo use Draggabilly as a jQuery plugin, you need to install and call [jQuery Bridget](https://github.com/desandro/jquery-bridget).\n\n```\nnpm install jquery-bridget\n```\n\n``` js\nvar $ = require('jquery');\nvar jQueryBridget = require('jquery-bridget');\nvar Draggabilly = require('draggabilly');\n\n// make Draggabilly a jQuery plugin\njQueryBridget( 'draggabilly', Draggabilly, $ );\n// now you can use $().draggabilly()\n$('.draggable').draggabilly({...})\n```\n\n## Browser support\n\nDraggabilly v3 supports Chrome 49+, Firefox 41+, Safari 14+ (mobile \u0026 desktop), and Edge 12+.\n\n- Use [Draggabilly v2](https://github.com/desandro/draggabilly/releases/tag/v2.4.1) for IE10 support and Safari 8 support.\n- Use [Draggabilly v2.1](https://github.com/desandro/draggabilly/releases/tag/v2.1.1) for Android 4+ and Safari 6+ support.\n- Use [Draggabilly v1](https://github.com/desandro/draggabilly/releases/tag/v1.2.4) for IE8 \u0026 9, and Android 2.3+ support.\n\n## License\n\nDraggabilly is released under the [MIT License](https://desandro.mit-license.org/). Have at it.\n\n---\n\nMade by [David DeSandro](https://desandro.com) 😻\n","funding_links":[],"categories":["JavaScript","工具","Tools","13. 页面交互"],"sub_categories":["13.17 拖拽组件 ###","13.17 拖拽组件"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesandro%2Fdraggabilly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesandro%2Fdraggabilly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesandro%2Fdraggabilly/lists"}