Draggable

The JavaScript Drag & Drop library your grandparents warned you about.

Github星跟蹤圖

CircleCI
npm version
codecov
Greenkeeper badge

Development

Draggable is no longer maintained by its original authors. Maintenance of this repo has been passed on to new collaborators and is no longer worked on by anyone at Shopify.

We are still looking for more maintainers! If anyone is interested in answering / triaging issues, reviewing / rejecting / approving PRs, and authoring code for bug fixes / new features — please send an email to curtis.dulmage (at) shopify (dot) com. You may be asked a few questions before obtaining collaboration permission, but if everything checks out, we will happily add you as a collaborator.

Current maintainers are:

Please ping the above handles when putting up PRs.


Get complete control over drag and drop behaviour with Draggable! Draggable abstracts
native browser events into a comprehensive API to create a custom drag and drop experience.
Draggable comes with additional modules: Sortable, Droppable, Swappable. Draggable
itself does not perform any sorting behaviour while dragging, but does the heavy lifting, e.g.
creates mirror, emits events, manages sensor events, makes elements draggable.

The additional modules are built on top of Draggable and therefore provide a similar API
interface, for more information read the documentation below.

Features

  • Works with native drag, mouse, touch and force touch events
  • Can extend dragging behaviour by hooking into draggables event life cycle
  • Can extend drag detection by adding sensors to draggable
  • The library is targeted ES6 first

Table of Contents

Install

You can install the library via npm.

npm install @shopify/draggable --save

or via yarn:

yarn add @shopify/draggable

or via CDN

<!-- Entire bundle -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable@1.0.0-beta.8/lib/draggable.bundle.js"></script>
<!-- legacy bundle for older browsers (IE11) -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable@1.0.0-beta.8/lib/draggable.bundle.legacy.js"></script>
<!-- Draggable only -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable@1.0.0-beta.8/lib/draggable.js"></script>
<!-- Sortable only -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable@1.0.0-beta.8/lib/sortable.js"></script>
<!-- Droppable only -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable@1.0.0-beta.8/lib/droppable.js"></script>
<!-- Swappable only -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable@1.0.0-beta.8/lib/swappable.js"></script>
<!-- Plugins only -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable@1.0.0-beta.8/lib/plugins.js"></script>

Browser Compatibility, Chrome, Firefox, IE, Opera, Safari, Edge, ----------------------------------------------------------------------------------------, -------------------------------------------------------------------------------------------, ----------------------------------------------------------------------------------------------------------------------------, -------------------------------------------------------------------------------------, ----------------------------------------------------------------------------------------, ----------------------------------------------------------------------------------, Latest ✔, Latest ✔, 11+ ✔, Latest ✔, Latest ✔, Latest ✔, ## Bundle sizes, Package name, ES6 bundle sizes, ES5 bundle sizes, --------------------------, ----------------, ----------------, draggable.bundle.js, ~11kb, ~19.2kb, draggable.bundle.legacy.js, ~19.2kb, ~25.63kb, draggable.js, ~8.06kb, ~15.36kb, sortable.js, ~8.93kb, ~16.51kb, swappable.js, ~8.56kb, ~16.14kb, droppable.js, ~8.8kb, ~16.55kb, plugins.js, ~2.37kb, ~8.76kb, plugins/collidable.js, ~1.45kb, ~7.81kb, plugins/snappable.js, ~1.19kb, ~6.94kb, plugins/swap-animation.js, ~1kb, ~6.65kb, ## Documentation

You can find the documentation for each module within their respective directories.

Running examples

To run the examples project locally, simply run the following from the draggable root:

yarn && yarn start

This will start a server that hosts the contents of examples/. It also watches for file
changes from both src/ and examples/src and reloads the browser.

Contributing

Contributions are more than welcome, the code base is still new and needs more love.

For more information, please checkout the contributing document.

Roadmap

We are currently working on v1.0.0-beta.8. Check out the project board to see tasks and follow progress on the release. Any Pull Requests should be pointed against the feature branch v1.0.0-beta.8.

Copyright (c) 2018 Shopify. See LICENSE.md for further details.

主要指標

概覽
名稱與所有者Shopify/draggable
主編程語言JavaScript
編程語言JavaScript (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2017-09-27 15:31:23
推送於2025-03-19 01:00:13
最后一次提交
發布數20
最新版本名稱v1.1.4 (發布於 2025-03-19 01:00:13)
第一版名稱v1.0.0-beta (發布於 )
用户参与
星數18.2k
關注者數617
派生數1.1k
提交數481
已啟用問題?
問題數305
打開的問題數112
拉請求數157
打開的拉請求數37
關閉的拉請求數112
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?