draggable README

The project's README from github.com/Shopify/draggable. As one markdown file: README.md.

npm version CI PRs Welcome Bundle size

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 max.hoffmann (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.


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

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 type="module">
  import {
    Draggable,
    Sortable,
    Droppable,
    Swappable,
  } from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/index.mjs';
</script>
<!-- Draggable only -->
<script type="module">
  import Draggable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Draggable/Draggable.mjs';
</script>
<!-- Sortable only -->
<script type="module">
  import Sortable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Sortable/Sortable.mjs';
</script>
<!-- Droppable only -->
<script type="module">
  import Droppable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Droppable/Droppable.mjs';
</script>
<!-- Swappable only -->
<script type="module">
  import Swappable from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Swappable/Swappable.mjs';
</script>
<!-- Plugins only -->
<script type="module">
  import * as Plugins from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/Plugins/index.mjs';
</script>
<!-- UMD browser -->
<script src="https://cdn.jsdelivr.net/npm/@shopify/draggable/build/umd/index.min.js"></script>
<script>
  console.log(window.Draggable);
</script>

Browser Compatibility

Check the "browserlist" property in package.json for more info

Chrome Firefox Opera Safari Edge
Last 3 versions ✔ Last 3 versions ✔ Last 3 versions ✔ Last 3 versions ✔ Last 3 versions ✔

Documentation

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

TypeScript

Draggable includes TypeScript definitions.

Documentation

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.

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

draggable (Shopify/draggable)

Searching Database…

18.5K ·GitHub
archived
这是什么东西?Draggable 是 Shopify 出品的一个开源 JavaScript 拖拽库。它把浏览器原生的拖拽事件封装成一套完整的 API,让你可以在浏览器里打造完全自定义的拖拽体验。
它是需要围绕它搭建的框架,还是一个普通的库?是一个普通的前端库,以 ES6 为主——不依赖任何框架。它自带 TypeScript 类型定义,各种附加模块(Sortable、Droppable、Swappable)都是在核心之上构建的。
我怎么把它加到项目里?用 npm install @shopify/draggable 安装(或者用 yarn add,或者通过 CDN 的 script 标签引入),然后通过它的 API 把它绑定到你想拖动的元素上。每个模块的文档都放在仓库里各自单独的目录中。
它还在积极维护吗?不——这个仓库已经归档,Shopify 不再维护它。维护工作交给了外部协作者,他们会修 bug、审查 PR,而且还在寻找更多维护者。
能不能先试玩一下,不用急着加到我自己的项目里?可以——仓库里自带一个 examples 项目。在仓库根目录运行 start 脚本,它就会在浏览器里打开 examples/ 文件夹,你修改库源码或示例文件时会实时刷新。
拖拽行为能自定义到什么程度?相当灵活:你可以挂接 Draggable 的事件生命周期来扩展拖拽功能,添加 sensor 来支持新的输入方式,还可以启用 Mirror、Scrollable、Collidable、ResizeMirror、Snappable、SwapAnimation、SortAnimation、Announcement 和 Focusable 等插件。
对用框架的人有什么支持吗?README 把社区的 Ember CLI 适配(在 GitHub 和 npm 上)列为相关资源。核心本身不依赖任何框架,并且自带 TypeScript 类型定义,方便使用类型的项目。
What are similar projects?Sortable, muuri, moveable, interact.js, mojs, dragula, dropzone, iscroll
Creator
Shopify
Size
5.9 MB
Stars
18.5K
Age
9y
Commits · 90 Days