The JavaScript Drag & Drop library your grandparents warned you about.
The npm package @shopify/draggable is a robust and flexible JavaScript library designed to enhance the drag-and-drop functionality of your web applications. Developed by Shopify, it aims to provide a smooth and accessible user interface experience, allowing for the seamless manipulation of elements within a webpage. One of the standout features of @shopify/draggable is its extensive support for touch devices, making it an ideal choice for modern, mobile-friendly web designs. Additionally, the library is lightweight and modular, enabling developers to include only the features they need, which keeps the load times fast and efficient.
To integrate this powerful drag-and-drop functionality into your project, simply use the command npm install @shopify/draggable. This command downloads and installs the library into your project, allowing you to begin implementing sophisticated drag-and-drop interfaces immediately. The package is well-maintained and regularly updated, ensuring compatibility with the latest web standards and technologies. Moreover, @shopify/draggable supports various customization options, giving developers the flexibility to tailor the behavior and appearance of the drag-and-drop elements to suit specific requirements.
@shopify/draggable stands out in the developer community due to its ease of use and comprehensive documentation. The library not only supports basic drag-and-drop operations but also offers advanced features such as sortable lists, swappable elements, and droppable zones, which can significantly enhance the interactivity of any website. By utilizing @shopify/draggable, developers can create more engaging and interactive user experiences, leading to increased user satisfaction and retention. Whether you're building a complex web application or a simple interactive feature, @shopify/draggable provides the tools necessary to implement effective and efficient drag-and-drop functionality.
[![npm version](https://img.shields.io/npm/v/@shopify/polaris-icons.svg?style=flat)](https://www...
Read moreA set of utilities, interfaces, and models that are common across all the platform...
Read moreThe JavaScript Drag & Drop library your grandparents warned you about...
Read more**[Join our team and work on libraries like this one.](https://www.shopify...
Read moreShopify GraphQL Client - A lightweight generic GraphQL JS client to interact with Shopify GraphQL...
Read moreShopify Storefront API Client - A lightweight JS client to interact with Shopify's Storefront...
Read moreThis is the Node.js wrapper of the runtime-agnostic [`@shopify/theme-check-common`](https://npm...
Read moreCore dependencies of this npm package and its dev dependencies.
@babel/core, @babel/plugin-proposal-decorators, @babel/preset-env, @babel/preset-typescript, @changesets/changelog-github, @changesets/cli, @rollup/plugin-babel, @rollup/plugin-commonjs, @rollup/plugin-node-resolve, @rollup/plugin-typescript, @shopify/eslint-plugin, @shopify/prettier-config, @shopify/typescript-configs, @types/jest, @types/node, concurrently, esdoc, esdoc-ecmascript-proposal-plugin, esdoc-standard-plugin, eslint, jest, jest-environment-jsdom, prettier, rollup, rollup-plugin-cleanup, rollup-plugin-includepaths, rollup-plugin-node-externals, timers, tsc-alias, typescript, uglify-js
A README file for the @shopify/draggable code repository. View Code
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
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>
Check the "browserlist" property in package.json for more info
Last 3 versions ✔ | Last 3 versions ✔ | Last 3 versions ✔ | Last 3 versions ✔ | Last 3 versions ✔ |
You can find the documentation for each module within their respective directories.
Draggable includes TypeScript definitions.
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.
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.