index.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link rel="icon" type="image/png" href="st/og-image.png">
  5. <title>SortableJS</title>
  6. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
  7. <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
  8. <link rel="stylesheet" type="text/css" href="st/theme.css">
  9. <meta charset="utf-8"/>
  10. <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  11. <meta property="og:image" content="/st/og-image.png"/>
  12. <meta name="keywords" content="sortable, reorder, list, javascript, html5, drag and drop, dnd, animation, groups, dnd, sortableJS"/>
  13. <meta name="description" content="Sortable — is a JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery required. Supports Meteor, AngularJS, React, Polymer, Vue, Knockout and any CSS library, e.g. Bootstrap."/>
  14. <meta name="viewport" content="width=device-width, initial-scale=0.5"/>
  15. </head>
  16. <body>
  17. <a href="https://github.com/SortableJS/Sortable"><img style="position: fixed; top: 0; right: 0; border: 0; z-index:99999" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
  18. <div class="container">
  19. <div class="text-center row header">
  20. <img class="mx-auto d-block" src="st/og-image.png" style="max-width: 200px; max-height: 200px" />
  21. <h1 class="col-12">SortableJS</h1>
  22. <h3 class="col-12 text-center">JavaScript library for reorderable drag-and-drop lists</h3>
  23. <div class="toc col-12 col-md-5 mt-3">
  24. <h5>Features</h5>
  25. <li><a href="#simple-list">Simple list</a></li>
  26. <li><a href="#shared-lists">Shared lists</a></li>
  27. <li><a href="#cloning">Cloning</a></li>
  28. <li><a href="#sorting-disabled">Disabling sorting</a></li>
  29. <li><a href="#handle">Handles</a></li>
  30. <li><a href="#filter">Filter</a></li>
  31. <li><a href="#thresholds">Thresholds</a></li>
  32. <h5>Examples</h5>
  33. <li><a href="#grid">Grid</a></li>
  34. <li><a href="#nested">Nested sortables</a></li>
  35. <h5>Plugins</h5>
  36. <li><a href="#multi-drag">MultiDrag</a></li>
  37. <li><a href="#swap">Swap</a></li>
  38. <h5><a href="#comparisons">Comparisons</a></h5>
  39. <h5><a href="#frameworks">Framework Support</a></h5>
  40. </div>
  41. </div>
  42. <div class="row">
  43. <h2 class="col-12">Features</h2>
  44. </div>
  45. <hr />
  46. <div id="simple-list" class="row">
  47. <h4 class="col-12">Simple list example</h4>
  48. <div id="example1" class="list-group col">
  49. <div class="list-group-item">Item 1</div>
  50. <div class="list-group-item">Item 2</div>
  51. <div class="list-group-item">Item 3</div>
  52. <div class="list-group-item">Item 4</div>
  53. <div class="list-group-item">Item 5</div>
  54. <div class="list-group-item">Item 6</div>
  55. </div>
  56. <div style="padding: 0" class="col-12">
  57. <pre class="prettyprint">new Sortable(example1, {
  58. animation: 150,
  59. ghostClass: 'blue-background-class'
  60. });</pre>
  61. </div>
  62. </div>
  63. <hr />
  64. <div id="shared-lists" class="row">
  65. <h4 class="col-12">Shared lists</h4>
  66. <div id="example2-left" class="list-group col">
  67. <div class="list-group-item">Item 1</div>
  68. <div class="list-group-item">Item 2</div>
  69. <div class="list-group-item">Item 3</div>
  70. <div class="list-group-item">Item 4</div>
  71. <div class="list-group-item">Item 5</div>
  72. <div class="list-group-item">Item 6</div>
  73. </div>
  74. <div id="example2-right" class="list-group col">
  75. <div class="list-group-item tinted">Item 1</div>
  76. <div class="list-group-item tinted">Item 2</div>
  77. <div class="list-group-item tinted">Item 3</div>
  78. <div class="list-group-item tinted">Item 4</div>
  79. <div class="list-group-item tinted">Item 5</div>
  80. <div class="list-group-item tinted">Item 6</div>
  81. </div>
  82. <div style="padding: 0" class="col-12">
  83. <pre class="prettyprint">new Sortable(example2Left, {
  84. group: 'shared', // set both lists to same group
  85. animation: 150
  86. });
  87. new Sortable(example2Right, {
  88. group: 'shared',
  89. animation: 150
  90. });</pre>
  91. </div>
  92. </div>
  93. <hr />
  94. <div id="cloning" class="row">
  95. <h4 class="col-12">Cloning</h4>
  96. <p class="col-12">Try dragging from one list to another. The item you drag will be cloned and the clone will stay in the original list.</p>
  97. <div id="example3-left" class="list-group col">
  98. <div class="list-group-item">Item 1</div>
  99. <div class="list-group-item">Item 2</div>
  100. <div class="list-group-item">Item 3</div>
  101. <div class="list-group-item">Item 4</div>
  102. <div class="list-group-item">Item 5</div>
  103. <div class="list-group-item">Item 6</div>
  104. </div>
  105. <div id="example3-right" class="list-group col">
  106. <div class="list-group-item tinted">Item 1</div>
  107. <div class="list-group-item tinted">Item 2</div>
  108. <div class="list-group-item tinted">Item 3</div>
  109. <div class="list-group-item tinted">Item 4</div>
  110. <div class="list-group-item tinted">Item 5</div>
  111. <div class="list-group-item tinted">Item 6</div>
  112. </div>
  113. <div style="padding: 0" class="col-12">
  114. <pre class="prettyprint">new Sortable(example3Left, {
  115. group: {
  116. name: 'shared',
  117. pull: 'clone' // To clone: set pull to 'clone'
  118. },
  119. animation: 150
  120. });
  121. new Sortable(example3Right, {
  122. group: {
  123. name: 'shared',
  124. pull: 'clone'
  125. },
  126. animation: 150
  127. });</pre>
  128. </div>
  129. </div>
  130. <hr />
  131. <div id="sorting-disabled" class="row">
  132. <h4 class="col-12">Disabling Sorting</h4>
  133. <p class="col-12">Try sorting the list on the left. It is not possible because it has it's <code>sort</code> option set to false. However, you can still drag from the list on the left to the list on the right.</p>
  134. <div id="example4-left" class="list-group col">
  135. <div class="list-group-item">Item 1</div>
  136. <div class="list-group-item">Item 2</div>
  137. <div class="list-group-item">Item 3</div>
  138. <div class="list-group-item">Item 4</div>
  139. <div class="list-group-item">Item 5</div>
  140. <div class="list-group-item">Item 6</div>
  141. </div>
  142. <div id="example4-right" class="list-group col">
  143. <div class="list-group-item tinted">Item 1</div>
  144. <div class="list-group-item tinted">Item 2</div>
  145. <div class="list-group-item tinted">Item 3</div>
  146. <div class="list-group-item tinted">Item 4</div>
  147. <div class="list-group-item tinted">Item 5</div>
  148. <div class="list-group-item tinted">Item 6</div>
  149. </div>
  150. <div style="padding: 0" class="col-12">
  151. <pre class="prettyprint">new Sortable(example4Left, {
  152. group: {
  153. name: 'shared',
  154. pull: 'clone',
  155. put: false // Do not allow items to be put into this list
  156. },
  157. animation: 150,
  158. sort: false // To disable sorting: set sort to false
  159. });
  160. new Sortable(example4Right, {
  161. group: 'shared',
  162. animation: 150
  163. });</pre>
  164. </div>
  165. </div>
  166. <hr />
  167. <div id="handle" class="row">
  168. <h4 class="col-12">Handle</h4>
  169. <div id="example5" class="list-group col">
  170. <div class="list-group-item"><i class="fas fa-arrows-alt handle"></i>&nbsp;&nbsp;Item 1</div>
  171. <div class="list-group-item"><i class="fas fa-arrows-alt handle"></i>&nbsp;&nbsp;Item 2</div>
  172. <div class="list-group-item"><i class="fas fa-arrows-alt handle"></i>&nbsp;&nbsp;Item 3</div>
  173. <div class="list-group-item"><i class="fas fa-arrows-alt handle"></i>&nbsp;&nbsp;Item 4</div>
  174. <div class="list-group-item"><i class="fas fa-arrows-alt handle"></i>&nbsp;&nbsp;Item 5</div>
  175. <div class="list-group-item"><i class="fas fa-arrows-alt handle"></i>&nbsp;&nbsp;Item 6</div>
  176. </div>
  177. <div style="padding: 0" class="col-12">
  178. <pre class="prettyprint">new Sortable(example5, {
  179. handle: '.handle', // handle's class
  180. animation: 150
  181. });</pre>
  182. </div>
  183. </div>
  184. <hr />
  185. <div id="filter" class="row">
  186. <h4 class="col-12">Filter</h4>
  187. <p class="col-12">Try dragging the item with a red background. It cannot be done, because that item is filtered out using the <code>filter</code> option.</p>
  188. <div id="example6" class="list-group col">
  189. <div class="list-group-item">Item 1</div>
  190. <div class="list-group-item">Item 2</div>
  191. <div class="list-group-item">Item 3</div>
  192. <div class="list-group-item bg-danger filtered">Filtered</div>
  193. <div class="list-group-item">Item 4</div>
  194. <div class="list-group-item">Item 5</div>
  195. </div>
  196. <div style="padding: 0" class="col-12">
  197. <pre class="prettyprint">new Sortable(example6, {
  198. filter: '.filtered', // 'filtered' class is not draggable
  199. animation: 150
  200. });</pre>
  201. </div>
  202. </div>
  203. <hr />
  204. <div id="thresholds" class="row">
  205. <h4 class="col-12">Thresholds</h4>
  206. <p class="col-12">Try modifying the inputs below to affect the swap thresholds. You can see the swap zones of the squares colored in dark blue, while the "dead zones" (that do not cause a swap) are colored in light blue.</p>
  207. <div id="example7" class="square-section col">
  208. <div class="square">
  209. <div style="display: none;" class="inverted-swap-threshold-indicator indicator-left"></div>
  210. <div class="swap-threshold-indicator"></div>
  211. <div style="display: none;" class="inverted-swap-threshold-indicator indicator-right"></div>
  212. <div class="num-indicator">1</div>
  213. </div><!--
  214. --><div class="square">
  215. <div style="display: none;" class="inverted-swap-threshold-indicator indicator-left"></div>
  216. <div class="swap-threshold-indicator"></div>
  217. <div style="display: none;" class="inverted-swap-threshold-indicator indicator-right"></div>
  218. <div class="num-indicator">2</div>
  219. </div>
  220. </div>
  221. <div class="col-12 input-section">
  222. <form>
  223. <div class="form-group row">
  224. <label class="col-sm-2 col-form-label" for="example7SwapThresholdInput">Swap Threshold</label>
  225. <div class="col-sm-8 col-form-label">
  226. <input min="0" max="1" value="1" step="0.01" type="range" class="form-control-range" id="example7SwapThresholdInput">
  227. </div>
  228. </div>
  229. <div class="form-group row">
  230. <div class="col-sm-2">Invert Swap</div>
  231. <div class="col-sm-10">
  232. <div class="form-check">
  233. <input class="form-check-input" type="checkbox" id="example7InvertSwapInput">
  234. </div>
  235. </div>
  236. </div>
  237. <div class="form-group row">
  238. <label class="col-sm-2 col-form-label" for="example7DirectionInput">Direction</label>
  239. <select class="col-sm-4 form-control" id="example7DirectionInput">
  240. <option value="h" selected>Horizontal</option>
  241. <option value="v">Vertical</option>
  242. </select>
  243. </div>
  244. </form>
  245. </div>
  246. <div style="padding: 0" class="col-12">
  247. <pre class="prettyprint">new Sortable(example7, {
  248. swapThreshold: <span id="example7SwapThresholdCode">1</span>,<span id="example7InvertSwapCode" style="display: none">
  249. invertSwap: true,</span>
  250. animation: 150
  251. });</pre>
  252. </div>
  253. </div>
  254. <div class="row">
  255. <h2 class="col-12">Examples</h2>
  256. </div>
  257. <hr />
  258. <div id="grid" class="row">
  259. <h4 class="col-12">Grid Example</h4>
  260. <div id="gridDemo" class="col">
  261. <div class="grid-square">Item 1</div><!--
  262. --><div class="grid-square">Item 2</div><!--
  263. --><div class="grid-square">Item 3</div><!--
  264. --><div class="grid-square">Item 4</div><!--
  265. --><div class="grid-square">Item 5</div><!--
  266. --><div class="grid-square">Item 6</div><!--
  267. --><div class="grid-square">Item 7</div><!--
  268. --><div class="grid-square">Item 8</div><!--
  269. --><div class="grid-square">Item 9</div><!--
  270. --><div class="grid-square">Item 10</div><!--
  271. --><div class="grid-square">Item 11</div><!--
  272. --><div class="grid-square">Item 12</div><!--
  273. --><div class="grid-square">Item 13</div><!--
  274. --><div class="grid-square">Item 14</div><!--
  275. --><div class="grid-square">Item 15</div><!--
  276. --><div class="grid-square">Item 16</div><!--
  277. --><div class="grid-square">Item 17</div><!--
  278. --><div class="grid-square">Item 18</div><!--
  279. --><div class="grid-square">Item 19</div><!--
  280. --><div class="grid-square">Item 20</div>
  281. </div>
  282. </div>
  283. <hr />
  284. <div id="nested" class="row">
  285. <h4 class="col-12">Nested Sortables Example</h4>
  286. <p class="col-12">NOTE: When using nested Sortables with animation, it is recommended that the <code>fallbackOnBody</code> option is set to true. <br />It is also always recommended that either the <code>invertSwap</code> option is set to true, or the <code>swapThreshold</code> option is lower than the default value of 1 (eg <code>0.65</code>).</p>
  287. <div id="nestedDemo" class="list-group col nested-sortable">
  288. <div class="list-group-item nested-1">Item 1.1
  289. <div class="list-group nested-sortable">
  290. <div class="list-group-item nested-2">Item 2.1</div>
  291. <div class="list-group-item nested-2">Item 2.2
  292. <div class="list-group nested-sortable">
  293. <div class="list-group-item nested-3">Item 3.1</div>
  294. <div class="list-group-item nested-3">Item 3.2</div>
  295. <div class="list-group-item nested-3">Item 3.3</div>
  296. <div class="list-group-item nested-3">Item 3.4</div>
  297. </div>
  298. </div>
  299. <div class="list-group-item nested-2">Item 2.3</div>
  300. <div class="list-group-item nested-2">Item 2.4</div>
  301. </div>
  302. </div>
  303. <div class="list-group-item nested-1">Item 1.2</div>
  304. <div class="list-group-item nested-1">Item 1.3</div>
  305. <div class="list-group-item nested-1">Item 1.4
  306. <div class="list-group nested-sortable">
  307. <div class="list-group-item nested-2">Item 2.1</div>
  308. <div class="list-group-item nested-2">Item 2.2</div>
  309. <div class="list-group-item nested-2">Item 2.3</div>
  310. <div class="list-group-item nested-2">Item 2.4</div>
  311. </div>
  312. </div>
  313. <div class="list-group-item nested-1">Item 1.5</div>
  314. </div>
  315. <div style="padding: 0" class="col-12">
  316. <pre class="prettyprint">// Loop through each nested sortable element
  317. for (var i = 0; i < nestedSortables.length; i++) {
  318. new Sortable(nestedSortables[i], {
  319. group: 'nested',
  320. animation: 150,
  321. fallbackOnBody: true,
  322. swapThreshold: 0.65
  323. });
  324. }</pre>
  325. </div>
  326. </div>
  327. <div class="row">
  328. <h2 class="col-12">Plugins</h2>
  329. </div>
  330. <hr />
  331. <div id="multi-drag" class="row">
  332. <h4 class="col-12">MultiDrag</h4>
  333. <p class="col-12">The <a target="_blank" href="https://github.com/SortableJS/Sortable/tree/master/plugins/MultiDrag">MultiDrag</a> plugin allows for multiple items to be dragged at a time. You can click to "select" multiple items, and then drag them as one item.</p>
  334. <div id="multiDragDemo" class="list-group col">
  335. <div class="list-group-item">Item 1</div>
  336. <div class="list-group-item">Item 2</div>
  337. <div class="list-group-item">Item 3</div>
  338. <div class="list-group-item">Item 4</div>
  339. <div class="list-group-item">Item 5</div>
  340. <div class="list-group-item">Item 6</div>
  341. </div>
  342. <div style="padding: 0" class="col-12">
  343. <pre class="prettyprint">new Sortable(multiDragDemo, {
  344. multiDrag: true, // Enable multi-drag
  345. selectedClass: 'selected', // The class applied to the selected items
  346. animation: 150
  347. });</pre>
  348. </div>
  349. </div>
  350. <hr />
  351. <div id="swap" class="row">
  352. <h4 class="col-12">Swap</h4>
  353. <p class="col-12">The <a target="_blank" href="https://github.com/SortableJS/Sortable/tree/master/plugins/Swap">Swap</a> plugin changes the behaviour of Sortable to allow for items to be swapped with eachother rather than sorted.</p>
  354. <div id="swapDemo" class="list-group col">
  355. <div class="list-group-item">Item 1</div>
  356. <div class="list-group-item">Item 2</div>
  357. <div class="list-group-item">Item 3</div>
  358. <div class="list-group-item">Item 4</div>
  359. <div class="list-group-item">Item 5</div>
  360. <div class="list-group-item">Item 6</div>
  361. </div>
  362. <div style="padding: 0" class="col-12">
  363. <pre class="prettyprint">new Sortable(swapDemo, {
  364. swap: true, // Enable swap plugin
  365. swapClass: 'highlight', // The class applied to the hovered swap item
  366. animation: 150
  367. });</pre>
  368. </div>
  369. </div>
  370. <hr />
  371. <div class="mt-4"></div>
  372. <div id="comparisons" class="row">
  373. <h2 class="col-12">Comparisons</h2>
  374. </div>
  375. <hr />
  376. <div class="row frameworks">
  377. <h2 class="col-12 text-center">jQuery-UI</h2>
  378. <iframe class="mx-auto" src="https://player.vimeo.com/video/311581236?title=0&byline=0&portrait=0" width="640" height="361" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
  379. <h2 class="col-12 text-center mt-5">Dragula</h2>
  380. <iframe class="mx-auto" src="https://player.vimeo.com/video/311584137?title=0&byline=0&portrait=0" width="640" height="361" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
  381. </div>
  382. <div class="mt-4"></div>
  383. <div id="frameworks" class="row">
  384. <h2 class="col-12">Framework Support</h2>
  385. </div>
  386. <hr />
  387. <div class="row frameworks">
  388. <h3 class="col-6">Vue</h3>
  389. <h3 class="col-6"><a target="_blank" href="https://github.com/SortableJS/Vue.Draggable">Vue.Draggable</a></h3>
  390. <h3 class="col-6">React</h3>
  391. <h3 class="col-6"><a target="_blank" href="https://github.com/SortableJS/react-sortablejs">react-sortablejs</a></h3>
  392. <h3 class="col-6">Angular</h3>
  393. <h3 class="col-6"><a target="_blank" href="https://github.com/SortableJS/ngx-sortablejs">ngx-sortablejs</a></h3>
  394. <h3 class="col-6">jQuery</h3>
  395. <h3 class="col-6"><a target="_blank" href="https://github.com/SortableJS/jquery-sortablejs">jquery-sortablejs</a></h3>
  396. <h3 class="col-6">Knockout</h3>
  397. <h3 class="col-6"><a target="_blank" href="https://github.com/SortableJS/knockout-sortablejs">knockout-sortablejs</a></h3>
  398. <h3 class="col-6">Meteor</h3>
  399. <h3 class="col-6"><a target="_blank" href="https://github.com/SortableJS/meteor-sortablejs">meteor-sortablejs</a></h3>
  400. <h3 class="col-6">Polymer</h3>
  401. <h3 class="col-6"><a target="_blank" href="https://github.com/SortableJS/polymer-sortablejs">polymer-sortablejs</a></h3>
  402. <h3 class="col-6">Ember</h3>
  403. <h3 class="col-6"><a target="_blank" href="https://github.com/SortableJS/ember-sortablejs">ember-sortablejs</a></h3>
  404. </div>
  405. </div>
  406. <!-- Latest Sortable -->
  407. <script src="./Sortable.js"></script>
  408. <script type="text/javascript" src="st/prettify/prettify.js"></script>
  409. <script type="text/javascript" src="st/prettify/run_prettify.js"></script>
  410. <script src="st/app.js"></script>
  411. </body>
  412. </html>