nodeskini 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +31 -0
  2. package/client/archive/bundle.js +11528 -0
  3. package/client/archive/golem.html +60 -0
  4. package/client/archive/golemClient.js +595 -0
  5. package/client/archive/golembundle.js +11634 -0
  6. package/client/archive/sequencer.html +43 -0
  7. package/client/archive/sequenceurClient.js +815 -0
  8. package/client/archive/stylegolem.css +158 -0
  9. package/client/archive/stylesequenceur.css +204 -0
  10. package/client/clientListe/Sortable-master/.circleci/config.yml +33 -0
  11. package/client/clientListe/Sortable-master/.editorconfig +15 -0
  12. package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/bug-report.md +73 -0
  13. package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/custom-template.md +48 -0
  14. package/client/clientListe/Sortable-master/.github/ISSUE_TEMPLATE/feature-request.md +41 -0
  15. package/client/clientListe/Sortable-master/.jshintrc +25 -0
  16. package/client/clientListe/Sortable-master/.testcaferc.json +7 -0
  17. package/client/clientListe/Sortable-master/CONTRIBUTING.md +26 -0
  18. package/client/clientListe/Sortable-master/LICENSE +21 -0
  19. package/client/clientListe/Sortable-master/README.md +813 -0
  20. package/client/clientListe/Sortable-master/Sortable.js +3709 -0
  21. package/client/clientListe/Sortable-master/Sortable.min.js +2 -0
  22. package/client/clientListe/Sortable-master/Sortable.min.old.js +2 -0
  23. package/client/clientListe/Sortable-master/Sortable.min.old.old.js +2 -0
  24. package/client/clientListe/Sortable-master/babel.config.js +27 -0
  25. package/client/clientListe/Sortable-master/bower.json +30 -0
  26. package/client/clientListe/Sortable-master/entry/entry-complete.js +8 -0
  27. package/client/clientListe/Sortable-master/entry/entry-core.js +19 -0
  28. package/client/clientListe/Sortable-master/entry/entry-defaults.js +19 -0
  29. package/client/clientListe/Sortable-master/index.html +460 -0
  30. package/client/clientListe/Sortable-master/modular/sortable.complete.esm.js +3701 -0
  31. package/client/clientListe/Sortable-master/modular/sortable.core.esm.js +3698 -0
  32. package/client/clientListe/Sortable-master/modular/sortable.esm.js +3699 -0
  33. package/client/clientListe/Sortable-master/package-lock.json +5704 -0
  34. package/client/clientListe/Sortable-master/package.json +56 -0
  35. package/client/clientListe/Sortable-master/plugins/AutoScroll/AutoScroll.js +270 -0
  36. package/client/clientListe/Sortable-master/plugins/AutoScroll/README.md +80 -0
  37. package/client/clientListe/Sortable-master/plugins/AutoScroll/index.js +1 -0
  38. package/client/clientListe/Sortable-master/plugins/MultiDrag/MultiDrag.js +617 -0
  39. package/client/clientListe/Sortable-master/plugins/MultiDrag/README.md +96 -0
  40. package/client/clientListe/Sortable-master/plugins/MultiDrag/index.js +1 -0
  41. package/client/clientListe/Sortable-master/plugins/OnSpill/OnSpill.js +79 -0
  42. package/client/clientListe/Sortable-master/plugins/OnSpill/README.md +60 -0
  43. package/client/clientListe/Sortable-master/plugins/OnSpill/index.js +1 -0
  44. package/client/clientListe/Sortable-master/plugins/README.md +178 -0
  45. package/client/clientListe/Sortable-master/plugins/Swap/README.md +55 -0
  46. package/client/clientListe/Sortable-master/plugins/Swap/Swap.js +90 -0
  47. package/client/clientListe/Sortable-master/plugins/Swap/index.js +1 -0
  48. package/client/clientListe/Sortable-master/scripts/banner.js +8 -0
  49. package/client/clientListe/Sortable-master/scripts/build.js +17 -0
  50. package/client/clientListe/Sortable-master/scripts/esm-build.js +28 -0
  51. package/client/clientListe/Sortable-master/scripts/minify.js +11 -0
  52. package/client/clientListe/Sortable-master/scripts/test-compat.js +30 -0
  53. package/client/clientListe/Sortable-master/scripts/test.js +21 -0
  54. package/client/clientListe/Sortable-master/scripts/umd-build.js +15 -0
  55. package/client/clientListe/Sortable-master/src/Animation.js +175 -0
  56. package/client/clientListe/Sortable-master/src/BrowserInfo.js +12 -0
  57. package/client/clientListe/Sortable-master/src/EventDispatcher.js +57 -0
  58. package/client/clientListe/Sortable-master/src/PluginManager.js +87 -0
  59. package/client/clientListe/Sortable-master/src/Sortable.js +1971 -0
  60. package/client/clientListe/Sortable-master/src/utils.js +556 -0
  61. package/client/clientListe/Sortable-master/st/app.js +224 -0
  62. package/client/clientListe/Sortable-master/st/iframe/frame.html +32 -0
  63. package/client/clientListe/Sortable-master/st/iframe/index.html +49 -0
  64. package/client/clientListe/Sortable-master/st/logo.png +0 -0
  65. package/client/clientListe/Sortable-master/st/og-image.png +0 -0
  66. package/client/clientListe/Sortable-master/st/prettify/prettify.css +1 -0
  67. package/client/clientListe/Sortable-master/st/prettify/prettify.js +46 -0
  68. package/client/clientListe/Sortable-master/st/prettify/run_prettify.js +64 -0
  69. package/client/clientListe/Sortable-master/st/saucelabs.svg +1 -0
  70. package/client/clientListe/Sortable-master/st/theme.css +254 -0
  71. package/client/clientListe/Sortable-master/tests/Sortable.compat.test.js +39 -0
  72. package/client/clientListe/Sortable-master/tests/Sortable.test.js +386 -0
  73. package/client/clientListe/Sortable-master/tests/dual-list.html +34 -0
  74. package/client/clientListe/Sortable-master/tests/empty-list.html +30 -0
  75. package/client/clientListe/Sortable-master/tests/filter.html +27 -0
  76. package/client/clientListe/Sortable-master/tests/handles.html +27 -0
  77. package/client/clientListe/Sortable-master/tests/nested.html +67 -0
  78. package/client/clientListe/Sortable-master/tests/single-list.html +25 -0
  79. package/client/clientListe/Sortable-master/tests/style.css +18 -0
  80. package/client/clientListe/clientListe.html +148 -0
  81. package/client/clientListe/clientListe.js +1508 -0
  82. package/client/clientListe/clientListebundle.js +13164 -0
  83. package/client/clientListe/images/poubelle.png +0 -0
  84. package/client/clientListe/images/start.png +0 -0
  85. package/client/clientListe/images/stop.png +0 -0
  86. package/client/clientListe/images/submit.png +0 -0
  87. package/client/clientListe/sortable-theme-bootstrap.css +90 -0
  88. package/client/configurateur/configReact.js +273 -0
  89. package/client/configurateur/configReactbundle.js +295 -0
  90. package/client/configurateur/configurateur.css +95 -0
  91. package/client/configurateur/configurateur.html +48 -0
  92. package/client/configurateur/lib/jexcel.css +755 -0
  93. package/client/configurateur/lib/jexcel.js +14970 -0
  94. package/client/configurateur/lib/jsuites.css +2801 -0
  95. package/client/configurateur/lib/jsuites.js +11822 -0
  96. package/client/configurateur/lib/react-dom.production.min.js +239 -0
  97. package/client/configurateur/lib/react.production.min.js +32 -0
  98. package/client/configurateur/src/configReact.js +247 -0
  99. package/client/controleur/clientcontroleur.js +536 -0
  100. package/client/controleur/clientcontroleur.test.js +282 -0
  101. package/client/controleur/controleur.html +51 -0
  102. package/client/controleur/controleurbundle.js +565 -0
  103. package/client/controleur/stylecontroleur.css +236 -0
  104. package/client/controleurHH/controleurHH.html +71 -0
  105. package/client/controleurHH/controleurHH.js +252 -0
  106. package/client/controleurHH/styles/index.css +320 -0
  107. package/client/controleurHH/styles/material.css +11552 -0
  108. package/client/parametrage/paramReact.js +473 -0
  109. package/client/parametrage/paramReactbundle.js +500 -0
  110. package/client/parametrage/parametrage.css +111 -0
  111. package/client/parametrage/parametrage.html +163 -0
  112. package/client/parametrage/src/paramReact.js +459 -0
  113. package/client/score/hash.js +83 -0
  114. package/client/score/p5.min.js +3 -0
  115. package/client/score/parto1.js +1171 -0
  116. package/client/score/parto1bundle.js +1181 -0
  117. package/client/score/processing.min.js +431 -0
  118. package/client/score/score.html +15 -0
  119. package/client/score/score.js +34 -0
  120. package/client/simulateurListe/simulateurFork.js +750 -0
  121. package/client/simulateurListe/simulateurFork.mjs +681 -0
  122. package/client/simulateurListe/simulateurForkSansReorg.js +569 -0
  123. package/client/simulateurListe/simulateurListe.js +628 -0
  124. package/myReact/archive/Nodeemitvaluedlocal1.hh.js +52 -0
  125. package/myReact/archive/abort-parNode.js +79 -0
  126. package/myReact/archive/abroNode.js +169 -0
  127. package/myReact/archive/abroNode2.js +80 -0
  128. package/myReact/archive/atom.compile.hh.js +51 -0
  129. package/myReact/archive/await-countNode.js +67 -0
  130. package/myReact/archive/await-nowvalNode.js +44 -0
  131. package/myReact/archive/callHH.js +96 -0
  132. package/myReact/archive/emit-if2.hh.compiled.js +113 -0
  133. package/myReact/archive/every1Node.js +35 -0
  134. package/myReact/archive/if-runNode.js +74 -0
  135. package/myReact/archive/if1Node.js +43 -0
  136. package/myReact/archive/makeawait.js +0 -0
  137. package/myReact/archive/myReact.old.js +684 -0
  138. package/myReact/archive/orchestration.js +281 -0
  139. package/myReact/archive/orchestration1.js +132 -0
  140. package/myReact/archive/orchestration1.xml +465 -0
  141. package/myReact/archive/orchestration2.js +161 -0
  142. package/myReact/archive/orchestrationHH.mano.js +280 -0
  143. package/myReact/archive/orchestrationHHTest.js +428 -0
  144. package/myReact/archive/orchestrationHHTest.xml +234 -0
  145. package/myReact/archive/orchestrationHHTestRun.js +104 -0
  146. package/myReact/archive/orchestrationHHTestRun.xml +34 -0
  147. package/myReact/archive/orchestrationTest0.js +178 -0
  148. package/myReact/archive/orchestrationTest1.js +181 -0
  149. package/myReact/archive/orchestrationTest2.js +281 -0
  150. package/myReact/archive/run3pointsNode.js +59 -0
  151. package/myReact/archive/runNode.js +123 -0
  152. package/myReact/archive/runNode2.js +91 -0
  153. package/myReact/archive/testAwait1.js +141 -0
  154. package/myReact/archive/testAwait1.xml +86 -0
  155. package/myReact/archive/testEvery1.js +122 -0
  156. package/myReact/archive/testEvery1.xml +79 -0
  157. package/myReact/archive/testHH1.js +135 -0
  158. package/myReact/archive/testHH1.xml +86 -0
  159. package/myReact/archive/testHH1revu.js +104 -0
  160. package/myReact/archive/testHH2.js +122 -0
  161. package/myReact/archive/testHH2.xml +79 -0
  162. package/myReact/archive/testHH3.js +130 -0
  163. package/myReact/archive/testHH3.xml +86 -0
  164. package/myReact/archive/testHHabort.js +121 -0
  165. package/myReact/archive/testHHabort.xml +83 -0
  166. package/myReact/archive/testMakeawait.js +202 -0
  167. package/myReact/archive/testRun1.js +168 -0
  168. package/myReact/archive/testRun1.xml +142 -0
  169. package/myReact/archive/titi.js +28 -0
  170. package/myReact/archive/titi.xml +110 -0
  171. package/myReact/archive/toto.js +73 -0
  172. package/myReact/archive/toto.xml +198 -0
  173. package/myReact/archive/trap-await-parallelNode.js +123 -0
  174. package/myReact/inutiles/hiver2022.xml +804 -0
  175. package/myReact/inutiles/hopeNode.xml +459 -0
  176. package/myReact/inutiles/mars2022.xml +871 -0
  177. package/myReact/inutiles/mystique1.xml +318 -0
  178. package/myReact/inutiles/mystiqueOSC.xml +277 -0
  179. package/myReact/inutiles/opus5Node.xml +1271 -0
  180. package/myReact/inutiles/opus5NodeLinux.xml +1241 -0
  181. package/myReact/inutiles/orchestrationHH.xml +541 -0
  182. package/myReact/inutiles/orchestrationHH2.xml +547 -0
  183. package/myReact/inutiles/testHH.xml +95 -0
  184. package/myReact/inutiles/trouveLaPercuTenor.xml +349 -0
  185. package/myReact/myReact.js +744 -0
  186. package/myReact/myReact.min.js +1 -0
  187. package/myReact/orchestrationHH.js +311 -0
  188. package/myReact/orchestrationHH.mjs +436 -0
  189. package/myReact/orchestrationHH.mjs.map +1 -0
  190. package/package.json +46 -0
  191. package/serveur/OSCandMidi.mjs +361 -0
  192. package/serveur/computeScore.mjs +415 -0
  193. package/serveur/controleDAW.mjs +1149 -0
  194. package/serveur/defaultSession.csv +2 -0
  195. package/serveur/defaultSkiniParametres.js +119 -0
  196. package/serveur/gameOSC.mjs +96 -0
  197. package/serveur/groupeClientsSons.mjs +1014 -0
  198. package/serveur/ipConfig.json +24 -0
  199. package/serveur/ipConfig127.json +19 -0
  200. package/serveur/ipConfig75.json +17 -0
  201. package/serveur/ipConfigBH.json +19 -0
  202. package/serveur/ipConfigLocal.json +19 -0
  203. package/serveur/midiConfig.json +26 -0
  204. package/serveur/midiConfigBH.json +26 -0
  205. package/serveur/midiConfigVoid.json +3 -0
  206. package/serveur/midimix.mjs +570 -0
  207. package/serveur/saveParam.mjs +159 -0
  208. package/serveur/skiniParametres.good.js +132 -0
  209. package/serveur/skiniParametres.js +106 -0
  210. package/serveur/utilsHHSkini.hh.js +64 -0
  211. package/serveur/utilsSkini.mjs +137 -0
  212. package/serveur/websocketServer.mjs +2052 -0
  213. package/serveur/workerInterfaceZ.mjs +327 -0
  214. package/serveur/workerSynchro.mjs +49 -0
  215. package/skini.mjs +141 -0
@@ -0,0 +1,1971 @@
1
+ /**!
2
+ * Sortable
3
+ * @author RubaXa <trash@rubaxa.org>
4
+ * @author owenm <owen23355@gmail.com>
5
+ * @license MIT
6
+ */
7
+
8
+ import { version } from '../package.json';
9
+
10
+ import { IE11OrLess, Edge, FireFox, Safari, IOS, ChromeForAndroid } from './BrowserInfo.js';
11
+
12
+ import AnimationStateManager from './Animation.js';
13
+
14
+ import PluginManager from './PluginManager.js';
15
+
16
+ import dispatchEvent from './EventDispatcher.js';
17
+
18
+ import {
19
+ on,
20
+ off,
21
+ closest,
22
+ toggleClass,
23
+ css,
24
+ matrix,
25
+ find,
26
+ getWindowScrollingElement,
27
+ getRect,
28
+ isScrolledPast,
29
+ getChild,
30
+ lastChild,
31
+ index,
32
+ getRelativeScrollOffset,
33
+ extend,
34
+ throttle,
35
+ scrollBy,
36
+ clone,
37
+ expando
38
+ } from './utils.js';
39
+
40
+
41
+ let pluginEvent = function(eventName, sortable, { evt: originalEvent, ...data } = {}) {
42
+ PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, {
43
+ dragEl,
44
+ parentEl,
45
+ ghostEl,
46
+ rootEl,
47
+ nextEl,
48
+ lastDownEl,
49
+ cloneEl,
50
+ cloneHidden,
51
+ dragStarted: moved,
52
+ putSortable,
53
+ activeSortable: Sortable.active,
54
+ originalEvent,
55
+
56
+ oldIndex,
57
+ oldDraggableIndex,
58
+ newIndex,
59
+ newDraggableIndex,
60
+
61
+ hideGhostForTarget: _hideGhostForTarget,
62
+ unhideGhostForTarget: _unhideGhostForTarget,
63
+
64
+
65
+ cloneNowHidden() {
66
+ cloneHidden = true;
67
+ },
68
+ cloneNowShown() {
69
+ cloneHidden = false;
70
+ },
71
+
72
+ dispatchSortableEvent(name) {
73
+ _dispatchEvent({ sortable, name, originalEvent });
74
+ },
75
+
76
+ ...data
77
+ });
78
+ };
79
+
80
+ function _dispatchEvent(info) {
81
+ dispatchEvent({
82
+ putSortable,
83
+ cloneEl,
84
+ targetEl: dragEl,
85
+ rootEl,
86
+ oldIndex,
87
+ oldDraggableIndex,
88
+ newIndex,
89
+ newDraggableIndex,
90
+ ...info
91
+ });
92
+ }
93
+
94
+
95
+ let dragEl,
96
+ parentEl,
97
+ ghostEl,
98
+ rootEl,
99
+ nextEl,
100
+ lastDownEl,
101
+
102
+ cloneEl,
103
+ cloneHidden,
104
+
105
+ oldIndex,
106
+ newIndex,
107
+ oldDraggableIndex,
108
+ newDraggableIndex,
109
+
110
+ activeGroup,
111
+ putSortable,
112
+
113
+ awaitingDragStarted = false,
114
+ ignoreNextClick = false,
115
+ sortables = [],
116
+
117
+ tapEvt,
118
+ touchEvt,
119
+ lastDx,
120
+ lastDy,
121
+ tapDistanceLeft,
122
+ tapDistanceTop,
123
+
124
+ moved,
125
+
126
+ lastTarget,
127
+ lastDirection,
128
+ pastFirstInvertThresh = false,
129
+ isCircumstantialInvert = false,
130
+
131
+ targetMoveDistance,
132
+
133
+ // For positioning ghost absolutely
134
+ ghostRelativeParent,
135
+ ghostRelativeParentInitialScroll = [], // (left, top)
136
+
137
+ _silent = false,
138
+ savedInputChecked = [];
139
+
140
+ /** @const */
141
+ const documentExists = typeof document !== 'undefined',
142
+
143
+ PositionGhostAbsolutely = IOS,
144
+
145
+ CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
146
+
147
+ // This will not pass for IE9, because IE9 DnD only works on anchors
148
+ supportDraggable = documentExists && !ChromeForAndroid && !IOS && ('draggable' in document.createElement('div')),
149
+
150
+ supportCssPointerEvents = (function() {
151
+ if (!documentExists) return;
152
+ // false when <= IE11
153
+ if (IE11OrLess) {
154
+ return false;
155
+ }
156
+ let el = document.createElement('x');
157
+ el.style.cssText = 'pointer-events:auto';
158
+ return el.style.pointerEvents === 'auto';
159
+ })(),
160
+
161
+ _detectDirection = function(el, options) {
162
+ let elCSS = css(el),
163
+ elWidth = parseInt(elCSS.width)
164
+ - parseInt(elCSS.paddingLeft)
165
+ - parseInt(elCSS.paddingRight)
166
+ - parseInt(elCSS.borderLeftWidth)
167
+ - parseInt(elCSS.borderRightWidth),
168
+ child1 = getChild(el, 0, options),
169
+ child2 = getChild(el, 1, options),
170
+ firstChildCSS = child1 && css(child1),
171
+ secondChildCSS = child2 && css(child2),
172
+ firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
173
+ secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
174
+
175
+ if (elCSS.display === 'flex') {
176
+ return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse'
177
+ ? 'vertical' : 'horizontal';
178
+ }
179
+
180
+ if (elCSS.display === 'grid') {
181
+ return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
182
+ }
183
+
184
+ if (child1 && firstChildCSS.float && firstChildCSS.float !== 'none') {
185
+ let touchingSideChild2 = firstChildCSS.float === 'left' ? 'left' : 'right';
186
+
187
+ return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ?
188
+ 'vertical' : 'horizontal';
189
+ }
190
+
191
+ return (child1 &&
192
+ (
193
+ firstChildCSS.display === 'block' ||
194
+ firstChildCSS.display === 'flex' ||
195
+ firstChildCSS.display === 'table' ||
196
+ firstChildCSS.display === 'grid' ||
197
+ firstChildWidth >= elWidth &&
198
+ elCSS[CSSFloatProperty] === 'none' ||
199
+ child2 &&
200
+ elCSS[CSSFloatProperty] === 'none' &&
201
+ firstChildWidth + secondChildWidth > elWidth
202
+ ) ?
203
+ 'vertical' : 'horizontal'
204
+ );
205
+ },
206
+
207
+ _dragElInRowColumn = function(dragRect, targetRect, vertical) {
208
+ let dragElS1Opp = vertical ? dragRect.left : dragRect.top,
209
+ dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
210
+ dragElOppLength = vertical ? dragRect.width : dragRect.height,
211
+ targetS1Opp = vertical ? targetRect.left : targetRect.top,
212
+ targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
213
+ targetOppLength = vertical ? targetRect.width : targetRect.height;
214
+
215
+ return (
216
+ dragElS1Opp === targetS1Opp ||
217
+ dragElS2Opp === targetS2Opp ||
218
+ (dragElS1Opp + dragElOppLength / 2) === (targetS1Opp + targetOppLength / 2)
219
+ );
220
+ },
221
+
222
+ /**
223
+ * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
224
+ * @param {Number} x X position
225
+ * @param {Number} y Y position
226
+ * @return {HTMLElement} Element of the first found nearest Sortable
227
+ */
228
+ _detectNearestEmptySortable = function(x, y) {
229
+ let ret;
230
+ sortables.some((sortable) => {
231
+ if (lastChild(sortable)) return;
232
+
233
+ let rect = getRect(sortable),
234
+ threshold = sortable[expando].options.emptyInsertThreshold,
235
+ insideHorizontally = x >= (rect.left - threshold) && x <= (rect.right + threshold),
236
+ insideVertically = y >= (rect.top - threshold) && y <= (rect.bottom + threshold);
237
+
238
+ if (threshold && insideHorizontally && insideVertically) {
239
+ return (ret = sortable);
240
+ }
241
+ });
242
+ return ret;
243
+ },
244
+
245
+ _prepareGroup = function (options) {
246
+ function toFn(value, pull) {
247
+ return function(to, from, dragEl, evt) {
248
+ let sameGroup = to.options.group.name &&
249
+ from.options.group.name &&
250
+ to.options.group.name === from.options.group.name;
251
+
252
+ if (value == null && (pull || sameGroup)) {
253
+ // Default pull value
254
+ // Default pull and put value if same group
255
+ return true;
256
+ } else if (value == null || value === false) {
257
+ return false;
258
+ } else if (pull && value === 'clone') {
259
+ return value;
260
+ } else if (typeof value === 'function') {
261
+ return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
262
+ } else {
263
+ let otherGroup = (pull ? to : from).options.group.name;
264
+
265
+ return (value === true ||
266
+ (typeof value === 'string' && value === otherGroup) ||
267
+ (value.join && value.indexOf(otherGroup) > -1));
268
+ }
269
+ };
270
+ }
271
+
272
+ let group = {};
273
+ let originalGroup = options.group;
274
+
275
+ if (!originalGroup || typeof originalGroup != 'object') {
276
+ originalGroup = {name: originalGroup};
277
+ }
278
+
279
+ group.name = originalGroup.name;
280
+ group.checkPull = toFn(originalGroup.pull, true);
281
+ group.checkPut = toFn(originalGroup.put);
282
+ group.revertClone = originalGroup.revertClone;
283
+
284
+ options.group = group;
285
+ },
286
+
287
+ _hideGhostForTarget = function() {
288
+ if (!supportCssPointerEvents && ghostEl) {
289
+ css(ghostEl, 'display', 'none');
290
+ }
291
+ },
292
+
293
+ _unhideGhostForTarget = function() {
294
+ if (!supportCssPointerEvents && ghostEl) {
295
+ css(ghostEl, 'display', '');
296
+ }
297
+ };
298
+
299
+
300
+ // #1184 fix - Prevent click event on fallback if dragged but item not changed position
301
+ if (documentExists) {
302
+ document.addEventListener('click', function(evt) {
303
+ if (ignoreNextClick) {
304
+ evt.preventDefault();
305
+ evt.stopPropagation && evt.stopPropagation();
306
+ evt.stopImmediatePropagation && evt.stopImmediatePropagation();
307
+ ignoreNextClick = false;
308
+ return false;
309
+ }
310
+ }, true);
311
+ }
312
+
313
+ let nearestEmptyInsertDetectEvent = function(evt) {
314
+ if (dragEl) {
315
+ evt = evt.touches ? evt.touches[0] : evt;
316
+ let nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
317
+
318
+ if (nearest) {
319
+ // Create imitation event
320
+ let event = {};
321
+ for (let i in evt) {
322
+ if (evt.hasOwnProperty(i)) {
323
+ event[i] = evt[i];
324
+ }
325
+ }
326
+ event.target = event.rootEl = nearest;
327
+ event.preventDefault = void 0;
328
+ event.stopPropagation = void 0;
329
+ nearest[expando]._onDragOver(event);
330
+ }
331
+ }
332
+ };
333
+
334
+
335
+ let _checkOutsideTargetEl = function(evt) {
336
+ if (dragEl) {
337
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
338
+ }
339
+ };
340
+
341
+
342
+ /**
343
+ * @class Sortable
344
+ * @param {HTMLElement} el
345
+ * @param {Object} [options]
346
+ */
347
+ function Sortable(el, options) {
348
+ if (!(el && el.nodeType && el.nodeType === 1)) {
349
+ throw `Sortable: \`el\` must be an HTMLElement, not ${ {}.toString.call(el) }`;
350
+ }
351
+
352
+ this.el = el; // root element
353
+ this.options = options = Object.assign({}, options);
354
+
355
+
356
+ // Export instance
357
+ el[expando] = this;
358
+
359
+ let defaults = {
360
+ group: null,
361
+ sort: true,
362
+ disabled: false,
363
+ store: null,
364
+ handle: null,
365
+ draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
366
+ swapThreshold: 1, // percentage; 0 <= x <= 1
367
+ invertSwap: false, // invert always
368
+ invertedSwapThreshold: null, // will be set to same as swapThreshold if default
369
+ removeCloneOnHide: true,
370
+ direction: function() {
371
+ return _detectDirection(el, this.options);
372
+ },
373
+ ghostClass: 'sortable-ghost',
374
+ chosenClass: 'sortable-chosen',
375
+ dragClass: 'sortable-drag',
376
+ ignore: 'a, img',
377
+ filter: null,
378
+ preventOnFilter: true,
379
+ animation: 0,
380
+ easing: null,
381
+ setData: function (dataTransfer, dragEl) {
382
+ dataTransfer.setData('Text', dragEl.textContent);
383
+ },
384
+ dropBubble: false,
385
+ dragoverBubble: false,
386
+ dataIdAttr: 'data-id',
387
+ delay: 0,
388
+ delayOnTouchOnly: false,
389
+ touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
390
+ forceFallback: false,
391
+ fallbackClass: 'sortable-fallback',
392
+ fallbackOnBody: false,
393
+ fallbackTolerance: 0,
394
+ fallbackOffset: {x: 0, y: 0},
395
+ supportPointer: Sortable.supportPointer !== false && ('PointerEvent' in window),
396
+ emptyInsertThreshold: 5
397
+ };
398
+
399
+ PluginManager.initializePlugins(this, el, defaults);
400
+
401
+ // Set default options
402
+ for (let name in defaults) {
403
+ !(name in options) && (options[name] = defaults[name]);
404
+ }
405
+
406
+ _prepareGroup(options);
407
+
408
+ // Bind all private methods
409
+ for (let fn in this) {
410
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
411
+ this[fn] = this[fn].bind(this);
412
+ }
413
+ }
414
+
415
+ // Setup drag mode
416
+ this.nativeDraggable = options.forceFallback ? false : supportDraggable;
417
+
418
+ if (this.nativeDraggable) {
419
+ // Touch start threshold cannot be greater than the native dragstart threshold
420
+ this.options.touchStartThreshold = 1;
421
+ }
422
+
423
+ // Bind events
424
+ if (options.supportPointer) {
425
+ on(el, 'pointerdown', this._onTapStart);
426
+ } else {
427
+ on(el, 'mousedown', this._onTapStart);
428
+ on(el, 'touchstart', this._onTapStart);
429
+ }
430
+
431
+ if (this.nativeDraggable) {
432
+ on(el, 'dragover', this);
433
+ on(el, 'dragenter', this);
434
+ }
435
+
436
+ sortables.push(this.el);
437
+
438
+ // Restore sorting
439
+ options.store && options.store.get && this.sort(options.store.get(this) || []);
440
+
441
+ // Add animation state manager
442
+ Object.assign(this, AnimationStateManager());
443
+ }
444
+
445
+ Sortable.prototype = /** @lends Sortable.prototype */ {
446
+ constructor: Sortable,
447
+
448
+ _isOutsideThisEl: function(target) {
449
+ if (!this.el.contains(target) && target !== this.el) {
450
+ lastTarget = null;
451
+ }
452
+ },
453
+
454
+ _getDirection: function(evt, target) {
455
+ return (typeof this.options.direction === 'function') ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
456
+ },
457
+
458
+ _onTapStart: function (/** Event|TouchEvent */evt) {
459
+ if (!evt.cancelable) return;
460
+ let _this = this,
461
+ el = this.el,
462
+ options = this.options,
463
+ preventOnFilter = options.preventOnFilter,
464
+ type = evt.type,
465
+ touch = (evt.touches && evt.touches[0]) || (evt.pointerType && evt.pointerType === 'touch' && evt),
466
+ target = (touch || evt).target,
467
+ originalTarget = evt.target.shadowRoot && ((evt.path && evt.path[0]) || (evt.composedPath && evt.composedPath()[0])) || target,
468
+ filter = options.filter;
469
+
470
+ _saveInputCheckedState(el);
471
+
472
+
473
+ // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
474
+ if (dragEl) {
475
+ return;
476
+ }
477
+
478
+ if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
479
+ return; // only left button and enabled
480
+ }
481
+
482
+ // cancel dnd if original target is content editable
483
+ if (originalTarget.isContentEditable) {
484
+ return;
485
+ }
486
+
487
+ // Safari ignores further event handling after mousedown
488
+ if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
489
+ return;
490
+ }
491
+
492
+ target = closest(target, options.draggable, el, false);
493
+
494
+
495
+ if (target && target.animated) {
496
+ return;
497
+ }
498
+
499
+ if (lastDownEl === target) {
500
+ // Ignoring duplicate `down`
501
+ return;
502
+ }
503
+
504
+ // Get the index of the dragged element within its parent
505
+ oldIndex = index(target);
506
+ oldDraggableIndex = index(target, options.draggable);
507
+
508
+ // Check filter
509
+ if (typeof filter === 'function') {
510
+ if (filter.call(this, evt, target, this)) {
511
+ _dispatchEvent({
512
+ sortable: _this,
513
+ rootEl: originalTarget,
514
+ name: 'filter',
515
+ targetEl: target,
516
+ toEl: el,
517
+ fromEl: el
518
+ });
519
+ pluginEvent('filter', _this, { evt });
520
+ preventOnFilter && evt.cancelable && evt.preventDefault();
521
+ return; // cancel dnd
522
+ }
523
+ }
524
+ else if (filter) {
525
+ filter = filter.split(',').some(function (criteria) {
526
+ criteria = closest(originalTarget, criteria.trim(), el, false);
527
+
528
+ if (criteria) {
529
+ _dispatchEvent({
530
+ sortable: _this,
531
+ rootEl: criteria,
532
+ name: 'filter',
533
+ targetEl: target,
534
+ fromEl: el,
535
+ toEl: el
536
+ });
537
+ pluginEvent('filter', _this, { evt });
538
+ return true;
539
+ }
540
+ });
541
+
542
+ if (filter) {
543
+ preventOnFilter && evt.cancelable && evt.preventDefault();
544
+ return; // cancel dnd
545
+ }
546
+ }
547
+
548
+ if (options.handle && !closest(originalTarget, options.handle, el, false)) {
549
+ return;
550
+ }
551
+
552
+ // Prepare `dragstart`
553
+ this._prepareDragStart(evt, touch, target);
554
+ },
555
+
556
+ _prepareDragStart: function (/** Event */evt, /** Touch */touch, /** HTMLElement */target) {
557
+ let _this = this,
558
+ el = _this.el,
559
+ options = _this.options,
560
+ ownerDocument = el.ownerDocument,
561
+ dragStartFn;
562
+
563
+ if (target && !dragEl && (target.parentNode === el)) {
564
+ let dragRect = getRect(target);
565
+ rootEl = el;
566
+ dragEl = target;
567
+ parentEl = dragEl.parentNode;
568
+ nextEl = dragEl.nextSibling;
569
+ lastDownEl = target;
570
+ activeGroup = options.group;
571
+
572
+ Sortable.dragged = dragEl;
573
+
574
+ tapEvt = {
575
+ target: dragEl,
576
+ clientX: (touch || evt).clientX,
577
+ clientY: (touch || evt).clientY
578
+ };
579
+
580
+ tapDistanceLeft = tapEvt.clientX - dragRect.left;
581
+ tapDistanceTop = tapEvt.clientY - dragRect.top;
582
+
583
+ this._lastX = (touch || evt).clientX;
584
+ this._lastY = (touch || evt).clientY;
585
+
586
+ dragEl.style['will-change'] = 'all';
587
+
588
+ dragStartFn = function () {
589
+ pluginEvent('delayEnded', _this, { evt });
590
+ if (Sortable.eventCanceled) {
591
+ _this._onDrop();
592
+ return;
593
+ }
594
+ // Delayed drag has been triggered
595
+ // we can re-enable the events: touchmove/mousemove
596
+ _this._disableDelayedDragEvents();
597
+
598
+ if (!FireFox && _this.nativeDraggable) {
599
+ dragEl.draggable = true;
600
+ }
601
+
602
+ // Bind the events: dragstart/dragend
603
+ _this._triggerDragStart(evt, touch);
604
+
605
+ // Drag start event
606
+ _dispatchEvent({
607
+ sortable: _this,
608
+ name: 'choose',
609
+ originalEvent: evt
610
+ });
611
+
612
+ // Chosen item
613
+ toggleClass(dragEl, options.chosenClass, true);
614
+ };
615
+
616
+ // Disable "draggable"
617
+ options.ignore.split(',').forEach(function (criteria) {
618
+ find(dragEl, criteria.trim(), _disableDraggable);
619
+ });
620
+
621
+ on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
622
+ on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
623
+ on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
624
+
625
+ on(ownerDocument, 'mouseup', _this._onDrop);
626
+ on(ownerDocument, 'touchend', _this._onDrop);
627
+ on(ownerDocument, 'touchcancel', _this._onDrop);
628
+
629
+ // Make dragEl draggable (must be before delay for FireFox)
630
+ if (FireFox && this.nativeDraggable) {
631
+ this.options.touchStartThreshold = 4;
632
+ dragEl.draggable = true;
633
+ }
634
+
635
+ pluginEvent('delayStart', this, { evt });
636
+
637
+ // Delay is impossible for native DnD in Edge or IE
638
+ if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
639
+ if (Sortable.eventCanceled) {
640
+ this._onDrop();
641
+ return;
642
+ }
643
+ // If the user moves the pointer or let go the click or touch
644
+ // before the delay has been reached:
645
+ // disable the delayed drag
646
+ on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
647
+ on(ownerDocument, 'touchend', _this._disableDelayedDrag);
648
+ on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
649
+ on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
650
+ on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
651
+ options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
652
+
653
+ _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
654
+ } else {
655
+ dragStartFn();
656
+ }
657
+ }
658
+ },
659
+
660
+ _delayedDragTouchMoveHandler: function (/** TouchEvent|PointerEvent **/e) {
661
+ let touch = e.touches ? e.touches[0] : e;
662
+ if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY))
663
+ >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))
664
+ ) {
665
+ this._disableDelayedDrag();
666
+ }
667
+ },
668
+
669
+ _disableDelayedDrag: function () {
670
+ dragEl && _disableDraggable(dragEl);
671
+ clearTimeout(this._dragStartTimer);
672
+
673
+ this._disableDelayedDragEvents();
674
+ },
675
+
676
+ _disableDelayedDragEvents: function () {
677
+ let ownerDocument = this.el.ownerDocument;
678
+ off(ownerDocument, 'mouseup', this._disableDelayedDrag);
679
+ off(ownerDocument, 'touchend', this._disableDelayedDrag);
680
+ off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
681
+ off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
682
+ off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
683
+ off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
684
+ },
685
+
686
+ _triggerDragStart: function (/** Event */evt, /** Touch */touch) {
687
+ touch = touch || (evt.pointerType == 'touch' && evt);
688
+
689
+ if (!this.nativeDraggable || touch) {
690
+ if (this.options.supportPointer) {
691
+ on(document, 'pointermove', this._onTouchMove);
692
+ } else if (touch) {
693
+ on(document, 'touchmove', this._onTouchMove);
694
+ } else {
695
+ on(document, 'mousemove', this._onTouchMove);
696
+ }
697
+ } else {
698
+ on(dragEl, 'dragend', this);
699
+ on(rootEl, 'dragstart', this._onDragStart);
700
+ }
701
+
702
+ try {
703
+ if (document.selection) {
704
+ // Timeout neccessary for IE9
705
+ _nextTick(function () {
706
+ document.selection.empty();
707
+ });
708
+ } else {
709
+ window.getSelection().removeAllRanges();
710
+ }
711
+ } catch (err) {
712
+ }
713
+ },
714
+
715
+ _dragStarted: function (fallback, evt) {
716
+ let _this = this;
717
+ awaitingDragStarted = false;
718
+ if (rootEl && dragEl) {
719
+ pluginEvent('dragStarted', this, { evt });
720
+
721
+ if (this.nativeDraggable) {
722
+ on(document, 'dragover', _checkOutsideTargetEl);
723
+ }
724
+ let options = this.options;
725
+
726
+ // Apply effect
727
+ !fallback && toggleClass(dragEl, options.dragClass, false);
728
+ toggleClass(dragEl, options.ghostClass, true);
729
+
730
+ Sortable.active = this;
731
+
732
+ fallback && this._appendGhost();
733
+
734
+ // Drag start event
735
+ _dispatchEvent({
736
+ sortable: this,
737
+ name: 'start',
738
+ originalEvent: evt
739
+ });
740
+ } else {
741
+ this._nulling();
742
+ }
743
+ },
744
+
745
+ _emulateDragOver: function () {
746
+ if (touchEvt) {
747
+ this._lastX = touchEvt.clientX;
748
+ this._lastY = touchEvt.clientY;
749
+
750
+ _hideGhostForTarget();
751
+
752
+ let target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
753
+ let parent = target;
754
+
755
+ while (target && target.shadowRoot) {
756
+ target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
757
+ if (target === parent) break;
758
+ parent = target;
759
+ }
760
+
761
+ dragEl.parentNode[expando]._isOutsideThisEl(target);
762
+
763
+ if (parent) {
764
+ do {
765
+ if (parent[expando]) {
766
+ let inserted;
767
+
768
+ inserted = parent[expando]._onDragOver({
769
+ clientX: touchEvt.clientX,
770
+ clientY: touchEvt.clientY,
771
+ target: target,
772
+ rootEl: parent
773
+ });
774
+
775
+ if (inserted && !this.options.dragoverBubble) {
776
+ break;
777
+ }
778
+ }
779
+
780
+ target = parent; // store last element
781
+ }
782
+ /* jshint boss:true */
783
+ while (parent = parent.parentNode);
784
+ }
785
+
786
+ _unhideGhostForTarget();
787
+ }
788
+ },
789
+
790
+
791
+ _onTouchMove: function (/**TouchEvent*/evt) {
792
+ if (tapEvt) {
793
+ let options = this.options,
794
+ fallbackTolerance = options.fallbackTolerance,
795
+ fallbackOffset = options.fallbackOffset,
796
+ touch = evt.touches ? evt.touches[0] : evt,
797
+ ghostMatrix = ghostEl && matrix(ghostEl, true),
798
+ scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
799
+ scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
800
+ relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
801
+ dx = ((touch.clientX - tapEvt.clientX)
802
+ + fallbackOffset.x) / (scaleX || 1)
803
+ + (relativeScrollOffset ? (relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0]) : 0) / (scaleX || 1),
804
+ dy = ((touch.clientY - tapEvt.clientY)
805
+ + fallbackOffset.y) / (scaleY || 1)
806
+ + (relativeScrollOffset ? (relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1]) : 0) / (scaleY || 1);
807
+
808
+ // only set the status to dragging, when we are actually dragging
809
+ if (!Sortable.active && !awaitingDragStarted) {
810
+ if (fallbackTolerance &&
811
+ Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance
812
+ ) {
813
+ return;
814
+ }
815
+ this._onDragStart(evt, true);
816
+ }
817
+
818
+ if (ghostEl) {
819
+ if (ghostMatrix) {
820
+ ghostMatrix.e += dx - (lastDx || 0);
821
+ ghostMatrix.f += dy - (lastDy || 0);
822
+ } else {
823
+ ghostMatrix = {
824
+ a: 1,
825
+ b: 0,
826
+ c: 0,
827
+ d: 1,
828
+ e: dx,
829
+ f: dy
830
+ };
831
+ }
832
+
833
+ let cssMatrix = `matrix(${ghostMatrix.a},${ghostMatrix.b},${ghostMatrix.c},${ghostMatrix.d},${ghostMatrix.e},${ghostMatrix.f})`;
834
+
835
+ css(ghostEl, 'webkitTransform', cssMatrix);
836
+ css(ghostEl, 'mozTransform', cssMatrix);
837
+ css(ghostEl, 'msTransform', cssMatrix);
838
+ css(ghostEl, 'transform', cssMatrix);
839
+
840
+ lastDx = dx;
841
+ lastDy = dy;
842
+
843
+ touchEvt = touch;
844
+ }
845
+
846
+ evt.cancelable && evt.preventDefault();
847
+ }
848
+ },
849
+
850
+ _appendGhost: function () {
851
+ // Bug if using scale(): https://stackoverflow.com/questions/2637058
852
+ // Not being adjusted for
853
+ if (!ghostEl) {
854
+ let container = this.options.fallbackOnBody ? document.body : rootEl,
855
+ rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
856
+ options = this.options;
857
+
858
+ // Position absolutely
859
+ if (PositionGhostAbsolutely) {
860
+ // Get relatively positioned parent
861
+ ghostRelativeParent = container;
862
+
863
+ while (
864
+ css(ghostRelativeParent, 'position') === 'static' &&
865
+ css(ghostRelativeParent, 'transform') === 'none' &&
866
+ ghostRelativeParent !== document
867
+ ) {
868
+ ghostRelativeParent = ghostRelativeParent.parentNode;
869
+ }
870
+
871
+ if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
872
+ if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
873
+
874
+ rect.top += ghostRelativeParent.scrollTop;
875
+ rect.left += ghostRelativeParent.scrollLeft;
876
+ } else {
877
+ ghostRelativeParent = getWindowScrollingElement();
878
+ }
879
+ ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
880
+ }
881
+
882
+
883
+ ghostEl = dragEl.cloneNode(true);
884
+
885
+ toggleClass(ghostEl, options.ghostClass, false);
886
+ toggleClass(ghostEl, options.fallbackClass, true);
887
+ toggleClass(ghostEl, options.dragClass, true);
888
+
889
+ css(ghostEl, 'transition', '');
890
+ css(ghostEl, 'transform', '');
891
+
892
+ css(ghostEl, 'box-sizing', 'border-box');
893
+ css(ghostEl, 'margin', 0);
894
+ css(ghostEl, 'top', rect.top);
895
+ css(ghostEl, 'left', rect.left);
896
+ css(ghostEl, 'width', rect.width);
897
+ css(ghostEl, 'height', rect.height);
898
+ css(ghostEl, 'opacity', '0.8');
899
+ css(ghostEl, 'position', (PositionGhostAbsolutely ? 'absolute' : 'fixed'));
900
+ css(ghostEl, 'zIndex', '100000');
901
+ css(ghostEl, 'pointerEvents', 'none');
902
+
903
+
904
+ Sortable.ghost = ghostEl;
905
+
906
+ container.appendChild(ghostEl);
907
+
908
+ // Set transform-origin
909
+ css(ghostEl, 'transform-origin', (tapDistanceLeft / parseInt(ghostEl.style.width) * 100) + '% ' + (tapDistanceTop / parseInt(ghostEl.style.height) * 100) + '%');
910
+ }
911
+ },
912
+
913
+ _onDragStart: function (/**Event*/evt, /**boolean*/fallback) {
914
+ let _this = this;
915
+ let dataTransfer = evt.dataTransfer;
916
+ let options = _this.options;
917
+
918
+ pluginEvent('dragStart', this, { evt });
919
+ if (Sortable.eventCanceled) {
920
+ this._onDrop();
921
+ return;
922
+ }
923
+
924
+ pluginEvent('setupClone', this);
925
+ if (!Sortable.eventCanceled) {
926
+ cloneEl = clone(dragEl);
927
+
928
+ cloneEl.draggable = false;
929
+ cloneEl.style['will-change'] = '';
930
+
931
+ this._hideClone();
932
+
933
+ toggleClass(cloneEl, this.options.chosenClass, false);
934
+ Sortable.clone = cloneEl;
935
+ }
936
+
937
+
938
+ // #1143: IFrame support workaround
939
+ _this.cloneId = _nextTick(function() {
940
+ pluginEvent('clone', _this);
941
+ if (Sortable.eventCanceled) return;
942
+
943
+ if (!_this.options.removeCloneOnHide) {
944
+ rootEl.insertBefore(cloneEl, dragEl);
945
+ }
946
+ _this._hideClone();
947
+
948
+ _dispatchEvent({
949
+ sortable: _this,
950
+ name: 'clone'
951
+ });
952
+ });
953
+
954
+
955
+ !fallback && toggleClass(dragEl, options.dragClass, true);
956
+
957
+ // Set proper drop events
958
+ if (fallback) {
959
+ ignoreNextClick = true;
960
+ _this._loopId = setInterval(_this._emulateDragOver, 50);
961
+ } else {
962
+ // Undo what was set in _prepareDragStart before drag started
963
+ off(document, 'mouseup', _this._onDrop);
964
+ off(document, 'touchend', _this._onDrop);
965
+ off(document, 'touchcancel', _this._onDrop);
966
+
967
+ if (dataTransfer) {
968
+ dataTransfer.effectAllowed = 'move';
969
+ options.setData && options.setData.call(_this, dataTransfer, dragEl);
970
+ }
971
+
972
+ on(document, 'drop', _this);
973
+
974
+ // #1276 fix:
975
+ css(dragEl, 'transform', 'translateZ(0)');
976
+ }
977
+
978
+ awaitingDragStarted = true;
979
+
980
+ _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
981
+ on(document, 'selectstart', _this);
982
+
983
+ moved = true;
984
+
985
+ if (Safari) {
986
+ css(document.body, 'user-select', 'none');
987
+ }
988
+ },
989
+
990
+
991
+ // Returns true - if no further action is needed (either inserted or another condition)
992
+ _onDragOver: function (/**Event*/evt) {
993
+ let el = this.el,
994
+ target = evt.target,
995
+ dragRect,
996
+ targetRect,
997
+ revert,
998
+ options = this.options,
999
+ group = options.group,
1000
+ activeSortable = Sortable.active,
1001
+ isOwner = (activeGroup === group),
1002
+ canSort = options.sort,
1003
+ fromSortable = (putSortable || activeSortable),
1004
+ vertical,
1005
+ _this = this,
1006
+ completedFired = false;
1007
+
1008
+ if (_silent) return;
1009
+
1010
+ function dragOverEvent(name, extra) {
1011
+ pluginEvent(name, _this, {
1012
+ evt,
1013
+ isOwner,
1014
+ axis: vertical ? 'vertical' : 'horizontal',
1015
+ revert,
1016
+ dragRect,
1017
+ targetRect,
1018
+ canSort,
1019
+ fromSortable,
1020
+ target,
1021
+ completed,
1022
+ onMove(target, after) {
1023
+ return onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
1024
+ },
1025
+ changed,
1026
+ ...extra
1027
+ });
1028
+ }
1029
+
1030
+ // Capture animation state
1031
+ function capture() {
1032
+ dragOverEvent('dragOverAnimationCapture');
1033
+
1034
+ _this.captureAnimationState();
1035
+ if (_this !== fromSortable) {
1036
+ fromSortable.captureAnimationState();
1037
+ }
1038
+ }
1039
+
1040
+ // Return invocation when dragEl is inserted (or completed)
1041
+ function completed(insertion) {
1042
+ dragOverEvent('dragOverCompleted', { insertion });
1043
+
1044
+ if (insertion) {
1045
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
1046
+ if (isOwner) {
1047
+ activeSortable._hideClone();
1048
+ } else {
1049
+ activeSortable._showClone(_this);
1050
+ }
1051
+
1052
+ if (_this !== fromSortable) {
1053
+ // Set ghost class to new sortable's ghost class
1054
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
1055
+ toggleClass(dragEl, options.ghostClass, true);
1056
+ }
1057
+
1058
+ if (putSortable !== _this && _this !== Sortable.active) {
1059
+ putSortable = _this;
1060
+ } else if (_this === Sortable.active && putSortable) {
1061
+ putSortable = null;
1062
+ }
1063
+
1064
+ // Animation
1065
+ if (fromSortable === _this) {
1066
+ _this._ignoreWhileAnimating = target;
1067
+ }
1068
+ _this.animateAll(function() {
1069
+ dragOverEvent('dragOverAnimationComplete');
1070
+ _this._ignoreWhileAnimating = null;
1071
+ });
1072
+ if (_this !== fromSortable) {
1073
+ fromSortable.animateAll();
1074
+ fromSortable._ignoreWhileAnimating = null;
1075
+ }
1076
+ }
1077
+
1078
+
1079
+ // Null lastTarget if it is not inside a previously swapped element
1080
+ if ((target === dragEl && !dragEl.animated) || (target === el && !target.animated)) {
1081
+ lastTarget = null;
1082
+ }
1083
+
1084
+ // no bubbling and not fallback
1085
+ if (!options.dragoverBubble && !evt.rootEl && target !== document) {
1086
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1087
+
1088
+ // Do not detect for empty insert if already inserted
1089
+ !insertion && nearestEmptyInsertDetectEvent(evt);
1090
+ }
1091
+
1092
+ !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
1093
+
1094
+ return (completedFired = true);
1095
+ }
1096
+
1097
+ // Call when dragEl has been inserted
1098
+ function changed() {
1099
+ newIndex = index(dragEl);
1100
+ newDraggableIndex = index(dragEl, options.draggable);
1101
+ _dispatchEvent({
1102
+ sortable: _this,
1103
+ name: 'change',
1104
+ toEl: el,
1105
+ newIndex,
1106
+ newDraggableIndex,
1107
+ originalEvent: evt
1108
+ });
1109
+ }
1110
+
1111
+
1112
+ if (evt.preventDefault !== void 0) {
1113
+ evt.cancelable && evt.preventDefault();
1114
+ }
1115
+
1116
+
1117
+ target = closest(target, options.draggable, el, true);
1118
+
1119
+ dragOverEvent('dragOver');
1120
+ if (Sortable.eventCanceled) return completedFired;
1121
+
1122
+ if (
1123
+ dragEl.contains(evt.target) ||
1124
+ target.animated && target.animatingX && target.animatingY ||
1125
+ _this._ignoreWhileAnimating === target
1126
+ ) {
1127
+ return completed(false);
1128
+ }
1129
+
1130
+ ignoreNextClick = false;
1131
+
1132
+ if (activeSortable && !options.disabled &&
1133
+ (isOwner
1134
+ ? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list
1135
+ : (
1136
+ putSortable === this ||
1137
+ (
1138
+ (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) &&
1139
+ group.checkPut(this, activeSortable, dragEl, evt)
1140
+ )
1141
+ )
1142
+ )
1143
+ ) {
1144
+ vertical = this._getDirection(evt, target) === 'vertical';
1145
+
1146
+ dragRect = getRect(dragEl);
1147
+
1148
+ dragOverEvent('dragOverValid');
1149
+ if (Sortable.eventCanceled) return completedFired;
1150
+
1151
+ if (revert) {
1152
+ parentEl = rootEl; // actualization
1153
+ capture();
1154
+
1155
+ this._hideClone();
1156
+
1157
+ dragOverEvent('revert');
1158
+
1159
+ if (!Sortable.eventCanceled) {
1160
+ if (nextEl) {
1161
+ rootEl.insertBefore(dragEl, nextEl);
1162
+ } else {
1163
+ rootEl.appendChild(dragEl);
1164
+ }
1165
+ }
1166
+
1167
+ return completed(true);
1168
+ }
1169
+
1170
+ let elLastChild = lastChild(el, options.draggable);
1171
+
1172
+ if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
1173
+ // If already at end of list: Do not insert
1174
+ if (elLastChild === dragEl) {
1175
+ return completed(false);
1176
+ }
1177
+
1178
+ // assign target only if condition is true
1179
+ if (elLastChild && el === evt.target) {
1180
+ target = elLastChild;
1181
+ }
1182
+
1183
+ if (target) {
1184
+ targetRect = getRect(target);
1185
+ }
1186
+
1187
+ if (onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
1188
+ capture();
1189
+ el.appendChild(dragEl);
1190
+ parentEl = el; // actualization
1191
+
1192
+ changed();
1193
+ return completed(true);
1194
+ }
1195
+ }
1196
+ else if (target.parentNode === el) {
1197
+ targetRect = getRect(target);
1198
+ let direction = 0,
1199
+ targetBeforeFirstSwap,
1200
+ differentLevel = dragEl.parentNode !== el,
1201
+ differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
1202
+ side1 = vertical ? 'top' : 'left',
1203
+ scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
1204
+ scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
1205
+
1206
+
1207
+ if (lastTarget !== target) {
1208
+ targetBeforeFirstSwap = targetRect[side1];
1209
+ pastFirstInvertThresh = false;
1210
+ isCircumstantialInvert = (!differentRowCol && options.invertSwap) || differentLevel;
1211
+ }
1212
+
1213
+ direction = _getSwapDirection(
1214
+ evt, target, targetRect, vertical,
1215
+ differentRowCol ? 1 : options.swapThreshold,
1216
+ options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold,
1217
+ isCircumstantialInvert,
1218
+ lastTarget === target
1219
+ );
1220
+
1221
+ let sibling;
1222
+
1223
+ if (direction !== 0) {
1224
+ // Check if target is beside dragEl in respective direction (ignoring hidden elements)
1225
+ let dragIndex = index(dragEl);
1226
+
1227
+ do {
1228
+ dragIndex -= direction;
1229
+ sibling = parentEl.children[dragIndex];
1230
+ } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
1231
+ }
1232
+ // If dragEl is already beside target: Do not insert
1233
+ if (
1234
+ direction === 0 ||
1235
+ sibling === target
1236
+ ) {
1237
+ return completed(false);
1238
+ }
1239
+
1240
+ lastTarget = target;
1241
+
1242
+ lastDirection = direction;
1243
+
1244
+ let nextSibling = target.nextElementSibling,
1245
+ after = false;
1246
+
1247
+ after = direction === 1;
1248
+
1249
+ let moveVector = onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
1250
+
1251
+ if (moveVector !== false) {
1252
+ if (moveVector === 1 || moveVector === -1) {
1253
+ after = (moveVector === 1);
1254
+ }
1255
+
1256
+ _silent = true;
1257
+ setTimeout(_unsilent, 30);
1258
+
1259
+ capture();
1260
+
1261
+ if (after && !nextSibling) {
1262
+ el.appendChild(dragEl);
1263
+ } else {
1264
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
1265
+ }
1266
+
1267
+ // Undo chrome's scroll adjustment (has no effect on other browsers)
1268
+ if (scrolledPastTop) {
1269
+ scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
1270
+ }
1271
+
1272
+ parentEl = dragEl.parentNode; // actualization
1273
+
1274
+ // must be done before animation
1275
+ if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
1276
+ targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
1277
+ }
1278
+ changed();
1279
+
1280
+ return completed(true);
1281
+ }
1282
+ }
1283
+
1284
+ if (el.contains(dragEl)) {
1285
+ return completed(false);
1286
+ }
1287
+ }
1288
+
1289
+ return false;
1290
+ },
1291
+
1292
+ _ignoreWhileAnimating: null,
1293
+
1294
+ _offMoveEvents: function() {
1295
+ off(document, 'mousemove', this._onTouchMove);
1296
+ off(document, 'touchmove', this._onTouchMove);
1297
+ off(document, 'pointermove', this._onTouchMove);
1298
+ off(document, 'dragover', nearestEmptyInsertDetectEvent);
1299
+ off(document, 'mousemove', nearestEmptyInsertDetectEvent);
1300
+ off(document, 'touchmove', nearestEmptyInsertDetectEvent);
1301
+ },
1302
+
1303
+ _offUpEvents: function () {
1304
+ let ownerDocument = this.el.ownerDocument;
1305
+
1306
+ off(ownerDocument, 'mouseup', this._onDrop);
1307
+ off(ownerDocument, 'touchend', this._onDrop);
1308
+ off(ownerDocument, 'pointerup', this._onDrop);
1309
+ off(ownerDocument, 'touchcancel', this._onDrop);
1310
+ off(document, 'selectstart', this);
1311
+ },
1312
+
1313
+ _onDrop: function (/**Event*/evt) {
1314
+ let el = this.el,
1315
+ options = this.options;
1316
+
1317
+ // Get the index of the dragged element within its parent
1318
+ newIndex = index(dragEl);
1319
+ newDraggableIndex = index(dragEl, options.draggable);
1320
+
1321
+ pluginEvent('drop', this, {
1322
+ evt
1323
+ });
1324
+
1325
+ parentEl = dragEl && dragEl.parentNode;
1326
+
1327
+ // Get again after plugin event
1328
+ newIndex = index(dragEl);
1329
+ newDraggableIndex = index(dragEl, options.draggable);
1330
+
1331
+ if (Sortable.eventCanceled) {
1332
+ this._nulling();
1333
+ return;
1334
+ }
1335
+
1336
+ awaitingDragStarted = false;
1337
+ isCircumstantialInvert = false;
1338
+ pastFirstInvertThresh = false;
1339
+
1340
+ clearInterval(this._loopId);
1341
+
1342
+ clearTimeout(this._dragStartTimer);
1343
+
1344
+ _cancelNextTick(this.cloneId);
1345
+ _cancelNextTick(this._dragStartId);
1346
+
1347
+ // Unbind events
1348
+ if (this.nativeDraggable) {
1349
+ off(document, 'drop', this);
1350
+ off(el, 'dragstart', this._onDragStart);
1351
+ }
1352
+ this._offMoveEvents();
1353
+ this._offUpEvents();
1354
+
1355
+
1356
+ if (Safari) {
1357
+ css(document.body, 'user-select', '');
1358
+ }
1359
+
1360
+ css(dragEl, 'transform', '');
1361
+
1362
+ if (evt) {
1363
+ if (moved) {
1364
+ evt.cancelable && evt.preventDefault();
1365
+ !options.dropBubble && evt.stopPropagation();
1366
+ }
1367
+
1368
+ ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
1369
+
1370
+ if (rootEl === parentEl || (putSortable && putSortable.lastPutMode !== 'clone')) {
1371
+ // Remove clone(s)
1372
+ cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
1373
+ }
1374
+
1375
+ if (dragEl) {
1376
+ if (this.nativeDraggable) {
1377
+ off(dragEl, 'dragend', this);
1378
+ }
1379
+
1380
+ _disableDraggable(dragEl);
1381
+ dragEl.style['will-change'] = '';
1382
+
1383
+ // Remove classes
1384
+ // ghostClass is added in dragStarted
1385
+ if (moved && !awaitingDragStarted) {
1386
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
1387
+ }
1388
+ toggleClass(dragEl, this.options.chosenClass, false);
1389
+
1390
+ // Drag stop event
1391
+ _dispatchEvent({
1392
+ sortable: this,
1393
+ name: 'unchoose',
1394
+ toEl: parentEl,
1395
+ newIndex: null,
1396
+ newDraggableIndex: null,
1397
+ originalEvent: evt
1398
+ });
1399
+
1400
+
1401
+ if (rootEl !== parentEl) {
1402
+
1403
+ if (newIndex >= 0) {
1404
+ // Add event
1405
+ _dispatchEvent({
1406
+ rootEl: parentEl,
1407
+ name: 'add',
1408
+ toEl: parentEl,
1409
+ fromEl: rootEl,
1410
+ originalEvent: evt
1411
+ });
1412
+
1413
+ // Remove event
1414
+ _dispatchEvent({
1415
+ sortable: this,
1416
+ name: 'remove',
1417
+ toEl: parentEl,
1418
+ originalEvent: evt
1419
+ });
1420
+
1421
+ // drag from one list and drop into another
1422
+ _dispatchEvent({
1423
+ rootEl: parentEl,
1424
+ name: 'sort',
1425
+ toEl: parentEl,
1426
+ fromEl: rootEl,
1427
+ originalEvent: evt
1428
+ });
1429
+
1430
+ _dispatchEvent({
1431
+ sortable: this,
1432
+ name: 'sort',
1433
+ toEl: parentEl,
1434
+ originalEvent: evt
1435
+ });
1436
+ }
1437
+
1438
+ putSortable && putSortable.save();
1439
+ } else {
1440
+ if (newIndex !== oldIndex) {
1441
+ if (newIndex >= 0) {
1442
+ // drag & drop within the same list
1443
+ _dispatchEvent({
1444
+ sortable: this,
1445
+ name: 'update',
1446
+ toEl: parentEl,
1447
+ originalEvent: evt
1448
+ });
1449
+
1450
+ _dispatchEvent({
1451
+ sortable: this,
1452
+ name: 'sort',
1453
+ toEl: parentEl,
1454
+ originalEvent: evt
1455
+ });
1456
+ }
1457
+ }
1458
+ }
1459
+
1460
+ if (Sortable.active) {
1461
+ /* jshint eqnull:true */
1462
+ if (newIndex == null || newIndex === -1) {
1463
+ newIndex = oldIndex;
1464
+ newDraggableIndex = oldDraggableIndex;
1465
+ }
1466
+
1467
+ _dispatchEvent({
1468
+ sortable: this,
1469
+ name: 'end',
1470
+ toEl: parentEl,
1471
+ originalEvent: evt
1472
+ });
1473
+
1474
+ // Save sorting
1475
+ this.save();
1476
+ }
1477
+ }
1478
+
1479
+ }
1480
+ this._nulling();
1481
+ },
1482
+
1483
+ _nulling: function() {
1484
+ pluginEvent('nulling', this);
1485
+
1486
+ rootEl =
1487
+ dragEl =
1488
+ parentEl =
1489
+ ghostEl =
1490
+ nextEl =
1491
+ cloneEl =
1492
+ lastDownEl =
1493
+ cloneHidden =
1494
+
1495
+ tapEvt =
1496
+ touchEvt =
1497
+
1498
+ moved =
1499
+ newIndex =
1500
+ newDraggableIndex =
1501
+ oldIndex =
1502
+ oldDraggableIndex =
1503
+
1504
+ lastTarget =
1505
+ lastDirection =
1506
+
1507
+ putSortable =
1508
+ activeGroup =
1509
+ Sortable.dragged =
1510
+ Sortable.ghost =
1511
+ Sortable.clone =
1512
+ Sortable.active = null;
1513
+
1514
+ savedInputChecked.forEach(function (el) {
1515
+ el.checked = true;
1516
+ });
1517
+
1518
+ savedInputChecked.length =
1519
+ lastDx =
1520
+ lastDy = 0;
1521
+ },
1522
+
1523
+ handleEvent: function (/**Event*/evt) {
1524
+ switch (evt.type) {
1525
+ case 'drop':
1526
+ case 'dragend':
1527
+ this._onDrop(evt);
1528
+ break;
1529
+
1530
+ case 'dragenter':
1531
+ case 'dragover':
1532
+ if (dragEl) {
1533
+ this._onDragOver(evt);
1534
+ _globalDragOver(evt);
1535
+ }
1536
+ break;
1537
+
1538
+ case 'selectstart':
1539
+ evt.preventDefault();
1540
+ break;
1541
+ }
1542
+ },
1543
+
1544
+
1545
+ /**
1546
+ * Serializes the item into an array of string.
1547
+ * @returns {String[]}
1548
+ */
1549
+ toArray: function () {
1550
+ let order = [],
1551
+ el,
1552
+ children = this.el.children,
1553
+ i = 0,
1554
+ n = children.length,
1555
+ options = this.options;
1556
+
1557
+ for (; i < n; i++) {
1558
+ el = children[i];
1559
+ if (closest(el, options.draggable, this.el, false)) {
1560
+ order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
1561
+ }
1562
+ }
1563
+
1564
+ return order;
1565
+ },
1566
+
1567
+
1568
+ /**
1569
+ * Sorts the elements according to the array.
1570
+ * @param {String[]} order order of the items
1571
+ */
1572
+ sort: function (order) {
1573
+ let items = {}, rootEl = this.el;
1574
+
1575
+ this.toArray().forEach(function (id, i) {
1576
+ let el = rootEl.children[i];
1577
+
1578
+ if (closest(el, this.options.draggable, rootEl, false)) {
1579
+ items[id] = el;
1580
+ }
1581
+ }, this);
1582
+
1583
+ order.forEach(function (id) {
1584
+ if (items[id]) {
1585
+ rootEl.removeChild(items[id]);
1586
+ rootEl.appendChild(items[id]);
1587
+ }
1588
+ });
1589
+ },
1590
+
1591
+
1592
+ /**
1593
+ * Save the current sorting
1594
+ */
1595
+ save: function () {
1596
+ let store = this.options.store;
1597
+ store && store.set && store.set(this);
1598
+ },
1599
+
1600
+
1601
+ /**
1602
+ * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
1603
+ * @param {HTMLElement} el
1604
+ * @param {String} [selector] default: `options.draggable`
1605
+ * @returns {HTMLElement|null}
1606
+ */
1607
+ closest: function (el, selector) {
1608
+ return closest(el, selector || this.options.draggable, this.el, false);
1609
+ },
1610
+
1611
+
1612
+ /**
1613
+ * Set/get option
1614
+ * @param {string} name
1615
+ * @param {*} [value]
1616
+ * @returns {*}
1617
+ */
1618
+ option: function (name, value) {
1619
+ let options = this.options;
1620
+
1621
+ if (value === void 0) {
1622
+ return options[name];
1623
+ } else {
1624
+ let modifiedValue = PluginManager.modifyOption(this, name, value);
1625
+ if (typeof modifiedValue !== 'undefined') {
1626
+ options[name] = modifiedValue;
1627
+ } else {
1628
+ options[name] = value;
1629
+ }
1630
+
1631
+ if (name === 'group') {
1632
+ _prepareGroup(options);
1633
+ }
1634
+ }
1635
+ },
1636
+
1637
+
1638
+ /**
1639
+ * Destroy
1640
+ */
1641
+ destroy: function () {
1642
+ pluginEvent('destroy', this);
1643
+ let el = this.el;
1644
+
1645
+ el[expando] = null;
1646
+
1647
+ off(el, 'mousedown', this._onTapStart);
1648
+ off(el, 'touchstart', this._onTapStart);
1649
+ off(el, 'pointerdown', this._onTapStart);
1650
+
1651
+ if (this.nativeDraggable) {
1652
+ off(el, 'dragover', this);
1653
+ off(el, 'dragenter', this);
1654
+ }
1655
+ // Remove draggable attributes
1656
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
1657
+ el.removeAttribute('draggable');
1658
+ });
1659
+
1660
+ this._onDrop();
1661
+
1662
+ this._disableDelayedDragEvents();
1663
+
1664
+ sortables.splice(sortables.indexOf(this.el), 1);
1665
+
1666
+ this.el = el = null;
1667
+ },
1668
+
1669
+ _hideClone: function() {
1670
+ if (!cloneHidden) {
1671
+ pluginEvent('hideClone', this);
1672
+ if (Sortable.eventCanceled) return;
1673
+
1674
+
1675
+ css(cloneEl, 'display', 'none');
1676
+ if (this.options.removeCloneOnHide && cloneEl.parentNode) {
1677
+ cloneEl.parentNode.removeChild(cloneEl);
1678
+ }
1679
+ cloneHidden = true;
1680
+ }
1681
+ },
1682
+
1683
+ _showClone: function(putSortable) {
1684
+ if (putSortable.lastPutMode !== 'clone') {
1685
+ this._hideClone();
1686
+ return;
1687
+ }
1688
+
1689
+
1690
+ if (cloneHidden) {
1691
+ pluginEvent('showClone', this);
1692
+ if (Sortable.eventCanceled) return;
1693
+
1694
+ // show clone at dragEl or original position
1695
+ if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
1696
+ rootEl.insertBefore(cloneEl, dragEl);
1697
+ } else if (nextEl) {
1698
+ rootEl.insertBefore(cloneEl, nextEl);
1699
+ } else {
1700
+ rootEl.appendChild(cloneEl);
1701
+ }
1702
+
1703
+ if (this.options.group.revertClone) {
1704
+ this.animate(dragEl, cloneEl);
1705
+ }
1706
+
1707
+ css(cloneEl, 'display', '');
1708
+ cloneHidden = false;
1709
+ }
1710
+ }
1711
+ };
1712
+
1713
+ function _globalDragOver(/**Event*/evt) {
1714
+ if (evt.dataTransfer) {
1715
+ evt.dataTransfer.dropEffect = 'move';
1716
+ }
1717
+ evt.cancelable && evt.preventDefault();
1718
+ }
1719
+
1720
+ function onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
1721
+ let evt,
1722
+ sortable = fromEl[expando],
1723
+ onMoveFn = sortable.options.onMove,
1724
+ retVal;
1725
+ // Support for new CustomEvent feature
1726
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
1727
+ evt = new CustomEvent('move', {
1728
+ bubbles: true,
1729
+ cancelable: true
1730
+ });
1731
+ } else {
1732
+ evt = document.createEvent('Event');
1733
+ evt.initEvent('move', true, true);
1734
+ }
1735
+
1736
+ evt.to = toEl;
1737
+ evt.from = fromEl;
1738
+ evt.dragged = dragEl;
1739
+ evt.draggedRect = dragRect;
1740
+ evt.related = targetEl || toEl;
1741
+ evt.relatedRect = targetRect || getRect(toEl);
1742
+ evt.willInsertAfter = willInsertAfter;
1743
+
1744
+ evt.originalEvent = originalEvent;
1745
+
1746
+ fromEl.dispatchEvent(evt);
1747
+
1748
+ if (onMoveFn) {
1749
+ retVal = onMoveFn.call(sortable, evt, originalEvent);
1750
+ }
1751
+
1752
+ return retVal;
1753
+ }
1754
+
1755
+ function _disableDraggable(el) {
1756
+ el.draggable = false;
1757
+ }
1758
+
1759
+ function _unsilent() {
1760
+ _silent = false;
1761
+ }
1762
+
1763
+
1764
+ function _ghostIsLast(evt, vertical, sortable) {
1765
+ let rect = getRect(lastChild(sortable.el, sortable.options.draggable));
1766
+ const spacer = 10;
1767
+
1768
+ return vertical ?
1769
+ (evt.clientX > rect.right + spacer || evt.clientX <= rect.right && evt.clientY > rect.bottom && evt.clientX >= rect.left) :
1770
+ (evt.clientX > rect.right && evt.clientY > rect.top || evt.clientX <= rect.right && evt.clientY > rect.bottom + spacer);
1771
+ }
1772
+
1773
+ function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
1774
+ let mouseOnAxis = vertical ? evt.clientY : evt.clientX,
1775
+ targetLength = vertical ? targetRect.height : targetRect.width,
1776
+ targetS1 = vertical ? targetRect.top : targetRect.left,
1777
+ targetS2 = vertical ? targetRect.bottom : targetRect.right,
1778
+ invert = false;
1779
+
1780
+
1781
+ if (!invertSwap) {
1782
+ // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
1783
+ if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) { // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
1784
+ // check if past first invert threshold on side opposite of lastDirection
1785
+ if (!pastFirstInvertThresh &&
1786
+ (lastDirection === 1 ?
1787
+ (
1788
+ mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2
1789
+ ) :
1790
+ (
1791
+ mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2
1792
+ )
1793
+ )
1794
+ )
1795
+ {
1796
+ // past first invert threshold, do not restrict inverted threshold to dragEl shadow
1797
+ pastFirstInvertThresh = true;
1798
+ }
1799
+
1800
+ if (!pastFirstInvertThresh) {
1801
+ // dragEl shadow (target move distance shadow)
1802
+ if (
1803
+ lastDirection === 1 ?
1804
+ (
1805
+ mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
1806
+ ) :
1807
+ (
1808
+ mouseOnAxis > targetS2 - targetMoveDistance
1809
+ )
1810
+ )
1811
+ {
1812
+ return -lastDirection;
1813
+ }
1814
+ } else {
1815
+ invert = true;
1816
+ }
1817
+ } else {
1818
+ // Regular
1819
+ if (
1820
+ mouseOnAxis > targetS1 + (targetLength * (1 - swapThreshold) / 2) &&
1821
+ mouseOnAxis < targetS2 - (targetLength * (1 - swapThreshold) / 2)
1822
+ ) {
1823
+ return _getInsertDirection(target);
1824
+ }
1825
+ }
1826
+ }
1827
+
1828
+ invert = invert || invertSwap;
1829
+
1830
+ if (invert) {
1831
+ // Invert of regular
1832
+ if (
1833
+ mouseOnAxis < targetS1 + (targetLength * invertedSwapThreshold / 2) ||
1834
+ mouseOnAxis > targetS2 - (targetLength * invertedSwapThreshold / 2)
1835
+ )
1836
+ {
1837
+ return ((mouseOnAxis > targetS1 + targetLength / 2) ? 1 : -1);
1838
+ }
1839
+ }
1840
+
1841
+ return 0;
1842
+ }
1843
+
1844
+ /**
1845
+ * Gets the direction dragEl must be swapped relative to target in order to make it
1846
+ * seem that dragEl has been "inserted" into that element's position
1847
+ * @param {HTMLElement} target The target whose position dragEl is being inserted at
1848
+ * @return {Number} Direction dragEl must be swapped
1849
+ */
1850
+ function _getInsertDirection(target) {
1851
+ if (index(dragEl) < index(target)) {
1852
+ return 1;
1853
+ } else {
1854
+ return -1;
1855
+ }
1856
+ }
1857
+
1858
+
1859
+ /**
1860
+ * Generate id
1861
+ * @param {HTMLElement} el
1862
+ * @returns {String}
1863
+ * @private
1864
+ */
1865
+ function _generateId(el) {
1866
+ let str = el.tagName + el.className + el.src + el.href + el.textContent,
1867
+ i = str.length,
1868
+ sum = 0;
1869
+
1870
+ while (i--) {
1871
+ sum += str.charCodeAt(i);
1872
+ }
1873
+
1874
+ return sum.toString(36);
1875
+ }
1876
+
1877
+ function _saveInputCheckedState(root) {
1878
+ savedInputChecked.length = 0;
1879
+
1880
+ let inputs = root.getElementsByTagName('input');
1881
+ let idx = inputs.length;
1882
+
1883
+ while (idx--) {
1884
+ let el = inputs[idx];
1885
+ el.checked && savedInputChecked.push(el);
1886
+ }
1887
+ }
1888
+
1889
+ function _nextTick(fn) {
1890
+ return setTimeout(fn, 0);
1891
+ }
1892
+
1893
+ function _cancelNextTick(id) {
1894
+ return clearTimeout(id);
1895
+ }
1896
+
1897
+ // Fixed #973:
1898
+ if (documentExists) {
1899
+ on(document, 'touchmove', function(evt) {
1900
+ if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
1901
+ evt.preventDefault();
1902
+ }
1903
+ });
1904
+ }
1905
+
1906
+
1907
+ // Export utils
1908
+ Sortable.utils = {
1909
+ on: on,
1910
+ off: off,
1911
+ css: css,
1912
+ find: find,
1913
+ is: function (el, selector) {
1914
+ return !!closest(el, selector, el, false);
1915
+ },
1916
+ extend: extend,
1917
+ throttle: throttle,
1918
+ closest: closest,
1919
+ toggleClass: toggleClass,
1920
+ clone: clone,
1921
+ index: index,
1922
+ nextTick: _nextTick,
1923
+ cancelNextTick: _cancelNextTick,
1924
+ detectDirection: _detectDirection,
1925
+ getChild: getChild
1926
+ };
1927
+
1928
+
1929
+ /**
1930
+ * Get the Sortable instance of an element
1931
+ * @param {HTMLElement} element The element
1932
+ * @return {Sortable|undefined} The instance of Sortable
1933
+ */
1934
+ Sortable.get = function(element) {
1935
+ return element[expando];
1936
+ };
1937
+
1938
+ /**
1939
+ * Mount a plugin to Sortable
1940
+ * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
1941
+ */
1942
+ Sortable.mount = function(...plugins) {
1943
+ if (plugins[0].constructor === Array) plugins = plugins[0];
1944
+
1945
+ plugins.forEach((plugin) => {
1946
+ if (!plugin.prototype || !plugin.prototype.constructor) {
1947
+ throw `Sortable: Mounted plugin must be a constructor function, not ${ {}.toString.call(plugin) }`;
1948
+ }
1949
+ if (plugin.utils) Sortable.utils = { ...Sortable.utils, ...plugin.utils };
1950
+
1951
+ PluginManager.mount(plugin);
1952
+ });
1953
+ };
1954
+
1955
+
1956
+
1957
+ /**
1958
+ * Create sortable instance
1959
+ * @param {HTMLElement} el
1960
+ * @param {Object} [options]
1961
+ */
1962
+ Sortable.create = function (el, options) {
1963
+ return new Sortable(el, options);
1964
+ };
1965
+
1966
+
1967
+ // Export
1968
+ Sortable.version = version;
1969
+
1970
+
1971
+ export default Sortable;