sortablejs 1.14.0 → 1.15.1
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.
- package/README.md +2 -2
- package/Sortable.js +675 -1093
- package/Sortable.min.js +2 -2
- package/modular/sortable.complete.esm.js +675 -1093
- package/modular/sortable.core.esm.js +675 -1094
- package/modular/sortable.esm.js +675 -1093
- package/package.json +2 -2
package/Sortable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**!
|
|
2
|
-
* Sortable 1.
|
|
2
|
+
* Sortable 1.15.1
|
|
3
3
|
* @author RubaXa <trash@rubaxa.org>
|
|
4
4
|
* @author owenm <owen23355@gmail.com>
|
|
5
5
|
* @license MIT
|
|
@@ -12,26 +12,20 @@
|
|
|
12
12
|
|
|
13
13
|
function ownKeys(object, enumerableOnly) {
|
|
14
14
|
var keys = Object.keys(object);
|
|
15
|
-
|
|
16
15
|
if (Object.getOwnPropertySymbols) {
|
|
17
16
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
-
|
|
19
17
|
if (enumerableOnly) {
|
|
20
18
|
symbols = symbols.filter(function (sym) {
|
|
21
19
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
keys.push.apply(keys, symbols);
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return keys;
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
function _objectSpread2(target) {
|
|
32
27
|
for (var i = 1; i < arguments.length; i++) {
|
|
33
28
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
34
|
-
|
|
35
29
|
if (i % 2) {
|
|
36
30
|
ownKeys(Object(source), true).forEach(function (key) {
|
|
37
31
|
_defineProperty(target, key, source[key]);
|
|
@@ -44,10 +38,8 @@
|
|
|
44
38
|
});
|
|
45
39
|
}
|
|
46
40
|
}
|
|
47
|
-
|
|
48
41
|
return target;
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
function _typeof(obj) {
|
|
52
44
|
"@babel/helpers - typeof";
|
|
53
45
|
|
|
@@ -60,10 +52,8 @@
|
|
|
60
52
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
61
53
|
};
|
|
62
54
|
}
|
|
63
|
-
|
|
64
55
|
return _typeof(obj);
|
|
65
56
|
}
|
|
66
|
-
|
|
67
57
|
function _defineProperty(obj, key, value) {
|
|
68
58
|
if (key in obj) {
|
|
69
59
|
Object.defineProperty(obj, key, {
|
|
@@ -75,53 +65,40 @@
|
|
|
75
65
|
} else {
|
|
76
66
|
obj[key] = value;
|
|
77
67
|
}
|
|
78
|
-
|
|
79
68
|
return obj;
|
|
80
69
|
}
|
|
81
|
-
|
|
82
70
|
function _extends() {
|
|
83
71
|
_extends = Object.assign || function (target) {
|
|
84
72
|
for (var i = 1; i < arguments.length; i++) {
|
|
85
73
|
var source = arguments[i];
|
|
86
|
-
|
|
87
74
|
for (var key in source) {
|
|
88
75
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
89
76
|
target[key] = source[key];
|
|
90
77
|
}
|
|
91
78
|
}
|
|
92
79
|
}
|
|
93
|
-
|
|
94
80
|
return target;
|
|
95
81
|
};
|
|
96
|
-
|
|
97
82
|
return _extends.apply(this, arguments);
|
|
98
83
|
}
|
|
99
|
-
|
|
100
84
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
101
85
|
if (source == null) return {};
|
|
102
86
|
var target = {};
|
|
103
87
|
var sourceKeys = Object.keys(source);
|
|
104
88
|
var key, i;
|
|
105
|
-
|
|
106
89
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
107
90
|
key = sourceKeys[i];
|
|
108
91
|
if (excluded.indexOf(key) >= 0) continue;
|
|
109
92
|
target[key] = source[key];
|
|
110
93
|
}
|
|
111
|
-
|
|
112
94
|
return target;
|
|
113
95
|
}
|
|
114
|
-
|
|
115
96
|
function _objectWithoutProperties(source, excluded) {
|
|
116
97
|
if (source == null) return {};
|
|
117
|
-
|
|
118
98
|
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
119
|
-
|
|
120
99
|
var key, i;
|
|
121
|
-
|
|
122
100
|
if (Object.getOwnPropertySymbols) {
|
|
123
101
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
124
|
-
|
|
125
102
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
126
103
|
key = sourceSymbolKeys[i];
|
|
127
104
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -129,22 +106,17 @@
|
|
|
129
106
|
target[key] = source[key];
|
|
130
107
|
}
|
|
131
108
|
}
|
|
132
|
-
|
|
133
109
|
return target;
|
|
134
110
|
}
|
|
135
|
-
|
|
136
111
|
function _toConsumableArray(arr) {
|
|
137
112
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
138
113
|
}
|
|
139
|
-
|
|
140
114
|
function _arrayWithoutHoles(arr) {
|
|
141
115
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
142
116
|
}
|
|
143
|
-
|
|
144
117
|
function _iterableToArray(iter) {
|
|
145
118
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
146
119
|
}
|
|
147
|
-
|
|
148
120
|
function _unsupportedIterableToArray(o, minLen) {
|
|
149
121
|
if (!o) return;
|
|
150
122
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -153,27 +125,22 @@
|
|
|
153
125
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
154
126
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
155
127
|
}
|
|
156
|
-
|
|
157
128
|
function _arrayLikeToArray(arr, len) {
|
|
158
129
|
if (len == null || len > arr.length) len = arr.length;
|
|
159
|
-
|
|
160
130
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
161
|
-
|
|
162
131
|
return arr2;
|
|
163
132
|
}
|
|
164
|
-
|
|
165
133
|
function _nonIterableSpread() {
|
|
166
134
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
167
135
|
}
|
|
168
136
|
|
|
169
|
-
var version = "1.
|
|
137
|
+
var version = "1.15.1";
|
|
170
138
|
|
|
171
139
|
function userAgent(pattern) {
|
|
172
140
|
if (typeof window !== 'undefined' && window.navigator) {
|
|
173
141
|
return !! /*@__PURE__*/navigator.userAgent.match(pattern);
|
|
174
142
|
}
|
|
175
143
|
}
|
|
176
|
-
|
|
177
144
|
var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
|
|
178
145
|
var Edge = userAgent(/Edge/i);
|
|
179
146
|
var FireFox = userAgent(/firefox/i);
|
|
@@ -185,23 +152,15 @@
|
|
|
185
152
|
capture: false,
|
|
186
153
|
passive: false
|
|
187
154
|
};
|
|
188
|
-
|
|
189
155
|
function on(el, event, fn) {
|
|
190
156
|
el.addEventListener(event, fn, !IE11OrLess && captureMode);
|
|
191
157
|
}
|
|
192
|
-
|
|
193
158
|
function off(el, event, fn) {
|
|
194
159
|
el.removeEventListener(event, fn, !IE11OrLess && captureMode);
|
|
195
160
|
}
|
|
196
|
-
|
|
197
|
-
function matches(
|
|
198
|
-
/**HTMLElement*/
|
|
199
|
-
el,
|
|
200
|
-
/**String*/
|
|
201
|
-
selector) {
|
|
161
|
+
function matches( /**HTMLElement*/el, /**String*/selector) {
|
|
202
162
|
if (!selector) return;
|
|
203
163
|
selector[0] === '>' && (selector = selector.substring(1));
|
|
204
|
-
|
|
205
164
|
if (el) {
|
|
206
165
|
try {
|
|
207
166
|
if (el.matches) {
|
|
@@ -215,39 +174,25 @@
|
|
|
215
174
|
return false;
|
|
216
175
|
}
|
|
217
176
|
}
|
|
218
|
-
|
|
219
177
|
return false;
|
|
220
178
|
}
|
|
221
|
-
|
|
222
179
|
function getParentOrHost(el) {
|
|
223
180
|
return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
|
|
224
181
|
}
|
|
225
|
-
|
|
226
|
-
function closest(
|
|
227
|
-
/**HTMLElement*/
|
|
228
|
-
el,
|
|
229
|
-
/**String*/
|
|
230
|
-
selector,
|
|
231
|
-
/**HTMLElement*/
|
|
232
|
-
ctx, includeCTX) {
|
|
182
|
+
function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
|
|
233
183
|
if (el) {
|
|
234
184
|
ctx = ctx || document;
|
|
235
|
-
|
|
236
185
|
do {
|
|
237
186
|
if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
|
|
238
187
|
return el;
|
|
239
188
|
}
|
|
240
|
-
|
|
241
189
|
if (el === ctx) break;
|
|
242
190
|
/* jshint boss:true */
|
|
243
191
|
} while (el = getParentOrHost(el));
|
|
244
192
|
}
|
|
245
|
-
|
|
246
193
|
return null;
|
|
247
194
|
}
|
|
248
|
-
|
|
249
195
|
var R_SPACE = /\s+/g;
|
|
250
|
-
|
|
251
196
|
function toggleClass(el, name, state) {
|
|
252
197
|
if (el && name) {
|
|
253
198
|
if (el.classList) {
|
|
@@ -258,10 +203,8 @@
|
|
|
258
203
|
}
|
|
259
204
|
}
|
|
260
205
|
}
|
|
261
|
-
|
|
262
206
|
function css(el, prop, val) {
|
|
263
207
|
var style = el && el.style;
|
|
264
|
-
|
|
265
208
|
if (style) {
|
|
266
209
|
if (val === void 0) {
|
|
267
210
|
if (document.defaultView && document.defaultView.getComputedStyle) {
|
|
@@ -269,83 +212,67 @@
|
|
|
269
212
|
} else if (el.currentStyle) {
|
|
270
213
|
val = el.currentStyle;
|
|
271
214
|
}
|
|
272
|
-
|
|
273
215
|
return prop === void 0 ? val : val[prop];
|
|
274
216
|
} else {
|
|
275
217
|
if (!(prop in style) && prop.indexOf('webkit') === -1) {
|
|
276
218
|
prop = '-webkit-' + prop;
|
|
277
219
|
}
|
|
278
|
-
|
|
279
220
|
style[prop] = val + (typeof val === 'string' ? '' : 'px');
|
|
280
221
|
}
|
|
281
222
|
}
|
|
282
223
|
}
|
|
283
|
-
|
|
284
224
|
function matrix(el, selfOnly) {
|
|
285
225
|
var appliedTransforms = '';
|
|
286
|
-
|
|
287
226
|
if (typeof el === 'string') {
|
|
288
227
|
appliedTransforms = el;
|
|
289
228
|
} else {
|
|
290
229
|
do {
|
|
291
230
|
var transform = css(el, 'transform');
|
|
292
|
-
|
|
293
231
|
if (transform && transform !== 'none') {
|
|
294
232
|
appliedTransforms = transform + ' ' + appliedTransforms;
|
|
295
233
|
}
|
|
296
234
|
/* jshint boss:true */
|
|
297
|
-
|
|
298
235
|
} while (!selfOnly && (el = el.parentNode));
|
|
299
236
|
}
|
|
300
|
-
|
|
301
237
|
var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
|
|
302
238
|
/*jshint -W056 */
|
|
303
|
-
|
|
304
239
|
return matrixFn && new matrixFn(appliedTransforms);
|
|
305
240
|
}
|
|
306
|
-
|
|
307
241
|
function find(ctx, tagName, iterator) {
|
|
308
242
|
if (ctx) {
|
|
309
243
|
var list = ctx.getElementsByTagName(tagName),
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
244
|
+
i = 0,
|
|
245
|
+
n = list.length;
|
|
313
246
|
if (iterator) {
|
|
314
247
|
for (; i < n; i++) {
|
|
315
248
|
iterator(list[i], i);
|
|
316
249
|
}
|
|
317
250
|
}
|
|
318
|
-
|
|
319
251
|
return list;
|
|
320
252
|
}
|
|
321
|
-
|
|
322
253
|
return [];
|
|
323
254
|
}
|
|
324
|
-
|
|
325
255
|
function getWindowScrollingElement() {
|
|
326
256
|
var scrollingElement = document.scrollingElement;
|
|
327
|
-
|
|
328
257
|
if (scrollingElement) {
|
|
329
258
|
return scrollingElement;
|
|
330
259
|
} else {
|
|
331
260
|
return document.documentElement;
|
|
332
261
|
}
|
|
333
262
|
}
|
|
334
|
-
/**
|
|
335
|
-
* Returns the "bounding client rect" of given element
|
|
336
|
-
* @param {HTMLElement} el The element whose boundingClientRect is wanted
|
|
337
|
-
* @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
|
|
338
|
-
* @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
|
|
339
|
-
* @param {[Boolean]} undoScale Whether the container's scale() should be undone
|
|
340
|
-
* @param {[HTMLElement]} container The parent the element will be placed in
|
|
341
|
-
* @return {Object} The boundingClientRect of el, with specified adjustments
|
|
342
|
-
*/
|
|
343
|
-
|
|
344
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Returns the "bounding client rect" of given element
|
|
266
|
+
* @param {HTMLElement} el The element whose boundingClientRect is wanted
|
|
267
|
+
* @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
|
|
268
|
+
* @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
|
|
269
|
+
* @param {[Boolean]} undoScale Whether the container's scale() should be undone
|
|
270
|
+
* @param {[HTMLElement]} container The parent the element will be placed in
|
|
271
|
+
* @return {Object} The boundingClientRect of el, with specified adjustments
|
|
272
|
+
*/
|
|
345
273
|
function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
|
|
346
274
|
if (!el.getBoundingClientRect && el !== window) return;
|
|
347
275
|
var elRect, top, left, bottom, right, height, width;
|
|
348
|
-
|
|
349
276
|
if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
|
|
350
277
|
elRect = el.getBoundingClientRect();
|
|
351
278
|
top = elRect.top;
|
|
@@ -362,17 +289,18 @@
|
|
|
362
289
|
height = window.innerHeight;
|
|
363
290
|
width = window.innerWidth;
|
|
364
291
|
}
|
|
365
|
-
|
|
366
292
|
if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
|
|
367
293
|
// Adjust for translate()
|
|
368
|
-
container = container || el.parentNode;
|
|
369
|
-
// Not needed on <= IE11
|
|
294
|
+
container = container || el.parentNode;
|
|
370
295
|
|
|
296
|
+
// solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
|
|
297
|
+
// Not needed on <= IE11
|
|
371
298
|
if (!IE11OrLess) {
|
|
372
299
|
do {
|
|
373
300
|
if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
|
|
374
|
-
var containerRect = container.getBoundingClientRect();
|
|
301
|
+
var containerRect = container.getBoundingClientRect();
|
|
375
302
|
|
|
303
|
+
// Set relative to edges of padding box of container
|
|
376
304
|
top -= containerRect.top + parseInt(css(container, 'border-top-width'));
|
|
377
305
|
left -= containerRect.left + parseInt(css(container, 'border-left-width'));
|
|
378
306
|
bottom = top + elRect.height;
|
|
@@ -380,17 +308,14 @@
|
|
|
380
308
|
break;
|
|
381
309
|
}
|
|
382
310
|
/* jshint boss:true */
|
|
383
|
-
|
|
384
311
|
} while (container = container.parentNode);
|
|
385
312
|
}
|
|
386
313
|
}
|
|
387
|
-
|
|
388
314
|
if (undoScale && el !== window) {
|
|
389
315
|
// Adjust for scale()
|
|
390
316
|
var elMatrix = matrix(container || el),
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
317
|
+
scaleX = elMatrix && elMatrix.a,
|
|
318
|
+
scaleY = elMatrix && elMatrix.d;
|
|
394
319
|
if (elMatrix) {
|
|
395
320
|
top /= scaleY;
|
|
396
321
|
left /= scaleX;
|
|
@@ -400,7 +325,6 @@
|
|
|
400
325
|
right = left + width;
|
|
401
326
|
}
|
|
402
327
|
}
|
|
403
|
-
|
|
404
328
|
return {
|
|
405
329
|
top: top,
|
|
406
330
|
left: left,
|
|
@@ -410,165 +334,160 @@
|
|
|
410
334
|
height: height
|
|
411
335
|
};
|
|
412
336
|
}
|
|
413
|
-
/**
|
|
414
|
-
* Checks if a side of an element is scrolled past a side of its parents
|
|
415
|
-
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
|
|
416
|
-
* @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
|
|
417
|
-
* @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
|
|
418
|
-
* @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
|
|
419
|
-
*/
|
|
420
|
-
|
|
421
337
|
|
|
338
|
+
/**
|
|
339
|
+
* Returns the content rect of the element (bounding rect minus border and padding)
|
|
340
|
+
* @param {HTMLElement} el
|
|
341
|
+
*/
|
|
342
|
+
function getContentRect(el) {
|
|
343
|
+
var rect = getRect(el);
|
|
344
|
+
var paddingLeft = parseInt(css(el, 'padding-left')),
|
|
345
|
+
paddingTop = parseInt(css(el, 'padding-top')),
|
|
346
|
+
paddingRight = parseInt(css(el, 'padding-right')),
|
|
347
|
+
paddingBottom = parseInt(css(el, 'padding-bottom'));
|
|
348
|
+
rect.top += paddingTop + parseInt(css(el, 'border-top-width'));
|
|
349
|
+
rect.left += paddingLeft + parseInt(css(el, 'border-left-width'));
|
|
350
|
+
// Client Width/Height includes padding only
|
|
351
|
+
rect.width = el.clientWidth - paddingLeft - paddingRight;
|
|
352
|
+
rect.height = el.clientHeight - paddingTop - paddingBottom;
|
|
353
|
+
rect.bottom = rect.top + rect.height;
|
|
354
|
+
rect.right = rect.left + rect.width;
|
|
355
|
+
return rect;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Checks if a side of an element is scrolled past a side of its parents
|
|
360
|
+
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
|
|
361
|
+
* @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
|
|
362
|
+
* @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
|
|
363
|
+
* @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
|
|
364
|
+
*/
|
|
422
365
|
function isScrolledPast(el, elSide, parentSide) {
|
|
423
366
|
var parent = getParentAutoScrollElement(el, true),
|
|
424
|
-
|
|
425
|
-
/* jshint boss:true */
|
|
367
|
+
elSideVal = getRect(el)[elSide];
|
|
426
368
|
|
|
369
|
+
/* jshint boss:true */
|
|
427
370
|
while (parent) {
|
|
428
371
|
var parentSideVal = getRect(parent)[parentSide],
|
|
429
|
-
|
|
430
|
-
|
|
372
|
+
visible = void 0;
|
|
431
373
|
if (parentSide === 'top' || parentSide === 'left') {
|
|
432
374
|
visible = elSideVal >= parentSideVal;
|
|
433
375
|
} else {
|
|
434
376
|
visible = elSideVal <= parentSideVal;
|
|
435
377
|
}
|
|
436
|
-
|
|
437
378
|
if (!visible) return parent;
|
|
438
379
|
if (parent === getWindowScrollingElement()) break;
|
|
439
380
|
parent = getParentAutoScrollElement(parent, false);
|
|
440
381
|
}
|
|
441
|
-
|
|
442
382
|
return false;
|
|
443
383
|
}
|
|
444
|
-
/**
|
|
445
|
-
* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
|
|
446
|
-
* and non-draggable elements
|
|
447
|
-
* @param {HTMLElement} el The parent element
|
|
448
|
-
* @param {Number} childNum The index of the child
|
|
449
|
-
* @param {Object} options Parent Sortable's options
|
|
450
|
-
* @return {HTMLElement} The child at index childNum, or null if not found
|
|
451
|
-
*/
|
|
452
|
-
|
|
453
384
|
|
|
385
|
+
/**
|
|
386
|
+
* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
|
|
387
|
+
* and non-draggable elements
|
|
388
|
+
* @param {HTMLElement} el The parent element
|
|
389
|
+
* @param {Number} childNum The index of the child
|
|
390
|
+
* @param {Object} options Parent Sortable's options
|
|
391
|
+
* @return {HTMLElement} The child at index childNum, or null if not found
|
|
392
|
+
*/
|
|
454
393
|
function getChild(el, childNum, options, includeDragEl) {
|
|
455
394
|
var currentChild = 0,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
395
|
+
i = 0,
|
|
396
|
+
children = el.children;
|
|
459
397
|
while (i < children.length) {
|
|
460
398
|
if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
|
|
461
399
|
if (currentChild === childNum) {
|
|
462
400
|
return children[i];
|
|
463
401
|
}
|
|
464
|
-
|
|
465
402
|
currentChild++;
|
|
466
403
|
}
|
|
467
|
-
|
|
468
404
|
i++;
|
|
469
405
|
}
|
|
470
|
-
|
|
471
406
|
return null;
|
|
472
407
|
}
|
|
473
|
-
/**
|
|
474
|
-
* Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
|
|
475
|
-
* @param {HTMLElement} el Parent element
|
|
476
|
-
* @param {selector} selector Any other elements that should be ignored
|
|
477
|
-
* @return {HTMLElement} The last child, ignoring ghostEl
|
|
478
|
-
*/
|
|
479
|
-
|
|
480
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
|
|
411
|
+
* @param {HTMLElement} el Parent element
|
|
412
|
+
* @param {selector} selector Any other elements that should be ignored
|
|
413
|
+
* @return {HTMLElement} The last child, ignoring ghostEl
|
|
414
|
+
*/
|
|
481
415
|
function lastChild(el, selector) {
|
|
482
416
|
var last = el.lastElementChild;
|
|
483
|
-
|
|
484
417
|
while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
|
|
485
418
|
last = last.previousElementSibling;
|
|
486
419
|
}
|
|
487
|
-
|
|
488
420
|
return last || null;
|
|
489
421
|
}
|
|
490
|
-
/**
|
|
491
|
-
* Returns the index of an element within its parent for a selected set of
|
|
492
|
-
* elements
|
|
493
|
-
* @param {HTMLElement} el
|
|
494
|
-
* @param {selector} selector
|
|
495
|
-
* @return {number}
|
|
496
|
-
*/
|
|
497
|
-
|
|
498
422
|
|
|
423
|
+
/**
|
|
424
|
+
* Returns the index of an element within its parent for a selected set of
|
|
425
|
+
* elements
|
|
426
|
+
* @param {HTMLElement} el
|
|
427
|
+
* @param {selector} selector
|
|
428
|
+
* @return {number}
|
|
429
|
+
*/
|
|
499
430
|
function index(el, selector) {
|
|
500
431
|
var index = 0;
|
|
501
|
-
|
|
502
432
|
if (!el || !el.parentNode) {
|
|
503
433
|
return -1;
|
|
504
434
|
}
|
|
505
|
-
/* jshint boss:true */
|
|
506
|
-
|
|
507
435
|
|
|
436
|
+
/* jshint boss:true */
|
|
508
437
|
while (el = el.previousElementSibling) {
|
|
509
438
|
if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
|
|
510
439
|
index++;
|
|
511
440
|
}
|
|
512
441
|
}
|
|
513
|
-
|
|
514
442
|
return index;
|
|
515
443
|
}
|
|
516
|
-
/**
|
|
517
|
-
* Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
|
|
518
|
-
* The value is returned in real pixels.
|
|
519
|
-
* @param {HTMLElement} el
|
|
520
|
-
* @return {Array} Offsets in the format of [left, top]
|
|
521
|
-
*/
|
|
522
|
-
|
|
523
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
|
|
447
|
+
* The value is returned in real pixels.
|
|
448
|
+
* @param {HTMLElement} el
|
|
449
|
+
* @return {Array} Offsets in the format of [left, top]
|
|
450
|
+
*/
|
|
524
451
|
function getRelativeScrollOffset(el) {
|
|
525
452
|
var offsetLeft = 0,
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
453
|
+
offsetTop = 0,
|
|
454
|
+
winScroller = getWindowScrollingElement();
|
|
529
455
|
if (el) {
|
|
530
456
|
do {
|
|
531
457
|
var elMatrix = matrix(el),
|
|
532
|
-
|
|
533
|
-
|
|
458
|
+
scaleX = elMatrix.a,
|
|
459
|
+
scaleY = elMatrix.d;
|
|
534
460
|
offsetLeft += el.scrollLeft * scaleX;
|
|
535
461
|
offsetTop += el.scrollTop * scaleY;
|
|
536
462
|
} while (el !== winScroller && (el = el.parentNode));
|
|
537
463
|
}
|
|
538
|
-
|
|
539
464
|
return [offsetLeft, offsetTop];
|
|
540
465
|
}
|
|
541
|
-
/**
|
|
542
|
-
* Returns the index of the object within the given array
|
|
543
|
-
* @param {Array} arr Array that may or may not hold the object
|
|
544
|
-
* @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
|
|
545
|
-
* @return {Number} The index of the object in the array, or -1
|
|
546
|
-
*/
|
|
547
|
-
|
|
548
466
|
|
|
467
|
+
/**
|
|
468
|
+
* Returns the index of the object within the given array
|
|
469
|
+
* @param {Array} arr Array that may or may not hold the object
|
|
470
|
+
* @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
|
|
471
|
+
* @return {Number} The index of the object in the array, or -1
|
|
472
|
+
*/
|
|
549
473
|
function indexOfObject(arr, obj) {
|
|
550
474
|
for (var i in arr) {
|
|
551
475
|
if (!arr.hasOwnProperty(i)) continue;
|
|
552
|
-
|
|
553
476
|
for (var key in obj) {
|
|
554
477
|
if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
|
|
555
478
|
}
|
|
556
479
|
}
|
|
557
|
-
|
|
558
480
|
return -1;
|
|
559
481
|
}
|
|
560
|
-
|
|
561
482
|
function getParentAutoScrollElement(el, includeSelf) {
|
|
562
483
|
// skip to window
|
|
563
484
|
if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
|
|
564
485
|
var elem = el;
|
|
565
486
|
var gotSelf = false;
|
|
566
|
-
|
|
567
487
|
do {
|
|
568
488
|
// we don't need to get elem css if it isn't even overflowing in the first place (performance)
|
|
569
489
|
if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
|
|
570
490
|
var elemCSS = css(elem);
|
|
571
|
-
|
|
572
491
|
if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
|
|
573
492
|
if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
|
|
574
493
|
if (gotSelf || includeSelf) return elem;
|
|
@@ -576,12 +495,9 @@
|
|
|
576
495
|
}
|
|
577
496
|
}
|
|
578
497
|
/* jshint boss:true */
|
|
579
|
-
|
|
580
498
|
} while (elem = elem.parentNode);
|
|
581
|
-
|
|
582
499
|
return getWindowScrollingElement();
|
|
583
500
|
}
|
|
584
|
-
|
|
585
501
|
function extend(dst, src) {
|
|
586
502
|
if (dst && src) {
|
|
587
503
|
for (var key in src) {
|
|
@@ -590,49 +506,39 @@
|
|
|
590
506
|
}
|
|
591
507
|
}
|
|
592
508
|
}
|
|
593
|
-
|
|
594
509
|
return dst;
|
|
595
510
|
}
|
|
596
|
-
|
|
597
511
|
function isRectEqual(rect1, rect2) {
|
|
598
512
|
return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
|
|
599
513
|
}
|
|
600
|
-
|
|
601
514
|
var _throttleTimeout;
|
|
602
|
-
|
|
603
515
|
function throttle(callback, ms) {
|
|
604
516
|
return function () {
|
|
605
517
|
if (!_throttleTimeout) {
|
|
606
518
|
var args = arguments,
|
|
607
|
-
|
|
608
|
-
|
|
519
|
+
_this = this;
|
|
609
520
|
if (args.length === 1) {
|
|
610
521
|
callback.call(_this, args[0]);
|
|
611
522
|
} else {
|
|
612
523
|
callback.apply(_this, args);
|
|
613
524
|
}
|
|
614
|
-
|
|
615
525
|
_throttleTimeout = setTimeout(function () {
|
|
616
526
|
_throttleTimeout = void 0;
|
|
617
527
|
}, ms);
|
|
618
528
|
}
|
|
619
529
|
};
|
|
620
530
|
}
|
|
621
|
-
|
|
622
531
|
function cancelThrottle() {
|
|
623
532
|
clearTimeout(_throttleTimeout);
|
|
624
533
|
_throttleTimeout = void 0;
|
|
625
534
|
}
|
|
626
|
-
|
|
627
535
|
function scrollBy(el, x, y) {
|
|
628
536
|
el.scrollLeft += x;
|
|
629
537
|
el.scrollTop += y;
|
|
630
538
|
}
|
|
631
|
-
|
|
632
539
|
function clone(el) {
|
|
633
540
|
var Polymer = window.Polymer;
|
|
634
541
|
var $ = window.jQuery || window.Zepto;
|
|
635
|
-
|
|
636
542
|
if (Polymer && Polymer.dom) {
|
|
637
543
|
return Polymer.dom(el).cloneNode(true);
|
|
638
544
|
} else if ($) {
|
|
@@ -641,7 +547,6 @@
|
|
|
641
547
|
return el.cloneNode(true);
|
|
642
548
|
}
|
|
643
549
|
}
|
|
644
|
-
|
|
645
550
|
function setRect(el, rect) {
|
|
646
551
|
css(el, 'position', 'absolute');
|
|
647
552
|
css(el, 'top', rect.top);
|
|
@@ -649,7 +554,6 @@
|
|
|
649
554
|
css(el, 'width', rect.width);
|
|
650
555
|
css(el, 'height', rect.height);
|
|
651
556
|
}
|
|
652
|
-
|
|
653
557
|
function unsetRect(el) {
|
|
654
558
|
css(el, 'position', '');
|
|
655
559
|
css(el, 'top', '');
|
|
@@ -657,12 +561,11 @@
|
|
|
657
561
|
css(el, 'width', '');
|
|
658
562
|
css(el, 'height', '');
|
|
659
563
|
}
|
|
660
|
-
|
|
661
564
|
var expando = 'Sortable' + new Date().getTime();
|
|
662
565
|
|
|
663
566
|
function AnimationStateManager() {
|
|
664
567
|
var animationStates = [],
|
|
665
|
-
|
|
568
|
+
animationCallbackId;
|
|
666
569
|
return {
|
|
667
570
|
captureAnimationState: function captureAnimationState() {
|
|
668
571
|
animationStates = [];
|
|
@@ -674,19 +577,16 @@
|
|
|
674
577
|
target: child,
|
|
675
578
|
rect: getRect(child)
|
|
676
579
|
});
|
|
580
|
+
var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
|
|
677
581
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
582
|
+
// If animating: compensate for current animation
|
|
681
583
|
if (child.thisAnimationDuration) {
|
|
682
584
|
var childMatrix = matrix(child, true);
|
|
683
|
-
|
|
684
585
|
if (childMatrix) {
|
|
685
586
|
fromRect.top -= childMatrix.f;
|
|
686
587
|
fromRect.left -= childMatrix.e;
|
|
687
588
|
}
|
|
688
589
|
}
|
|
689
|
-
|
|
690
590
|
child.fromRect = fromRect;
|
|
691
591
|
});
|
|
692
592
|
},
|
|
@@ -700,54 +600,47 @@
|
|
|
700
600
|
},
|
|
701
601
|
animateAll: function animateAll(callback) {
|
|
702
602
|
var _this = this;
|
|
703
|
-
|
|
704
603
|
if (!this.options.animation) {
|
|
705
604
|
clearTimeout(animationCallbackId);
|
|
706
605
|
if (typeof callback === 'function') callback();
|
|
707
606
|
return;
|
|
708
607
|
}
|
|
709
|
-
|
|
710
608
|
var animating = false,
|
|
711
|
-
|
|
609
|
+
animationTime = 0;
|
|
712
610
|
animationStates.forEach(function (state) {
|
|
713
611
|
var time = 0,
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
612
|
+
target = state.target,
|
|
613
|
+
fromRect = target.fromRect,
|
|
614
|
+
toRect = getRect(target),
|
|
615
|
+
prevFromRect = target.prevFromRect,
|
|
616
|
+
prevToRect = target.prevToRect,
|
|
617
|
+
animatingRect = state.rect,
|
|
618
|
+
targetMatrix = matrix(target, true);
|
|
722
619
|
if (targetMatrix) {
|
|
723
620
|
// Compensate for current animation
|
|
724
621
|
toRect.top -= targetMatrix.f;
|
|
725
622
|
toRect.left -= targetMatrix.e;
|
|
726
623
|
}
|
|
727
|
-
|
|
728
624
|
target.toRect = toRect;
|
|
729
|
-
|
|
730
625
|
if (target.thisAnimationDuration) {
|
|
731
626
|
// Could also check if animatingRect is between fromRect and toRect
|
|
732
|
-
if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
|
|
627
|
+
if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
|
|
628
|
+
// Make sure animatingRect is on line between toRect & fromRect
|
|
733
629
|
(animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
|
|
734
630
|
// If returning to same place as started from animation and on same axis
|
|
735
631
|
time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
|
|
736
632
|
}
|
|
737
|
-
}
|
|
738
|
-
|
|
633
|
+
}
|
|
739
634
|
|
|
635
|
+
// if fromRect != toRect: animate
|
|
740
636
|
if (!isRectEqual(toRect, fromRect)) {
|
|
741
637
|
target.prevFromRect = fromRect;
|
|
742
638
|
target.prevToRect = toRect;
|
|
743
|
-
|
|
744
639
|
if (!time) {
|
|
745
640
|
time = _this.options.animation;
|
|
746
641
|
}
|
|
747
|
-
|
|
748
642
|
_this.animate(target, animatingRect, toRect, time);
|
|
749
643
|
}
|
|
750
|
-
|
|
751
644
|
if (time) {
|
|
752
645
|
animating = true;
|
|
753
646
|
animationTime = Math.max(animationTime, time);
|
|
@@ -763,7 +656,6 @@
|
|
|
763
656
|
}
|
|
764
657
|
});
|
|
765
658
|
clearTimeout(animationCallbackId);
|
|
766
|
-
|
|
767
659
|
if (!animating) {
|
|
768
660
|
if (typeof callback === 'function') callback();
|
|
769
661
|
} else {
|
|
@@ -771,7 +663,6 @@
|
|
|
771
663
|
if (typeof callback === 'function') callback();
|
|
772
664
|
}, animationTime);
|
|
773
665
|
}
|
|
774
|
-
|
|
775
666
|
animationStates = [];
|
|
776
667
|
},
|
|
777
668
|
animate: function animate(target, currentRect, toRect, duration) {
|
|
@@ -779,10 +670,10 @@
|
|
|
779
670
|
css(target, 'transition', '');
|
|
780
671
|
css(target, 'transform', '');
|
|
781
672
|
var elMatrix = matrix(this.el),
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
673
|
+
scaleX = elMatrix && elMatrix.a,
|
|
674
|
+
scaleY = elMatrix && elMatrix.d,
|
|
675
|
+
translateX = (currentRect.left - toRect.left) / (scaleX || 1),
|
|
676
|
+
translateY = (currentRect.top - toRect.top) / (scaleY || 1);
|
|
786
677
|
target.animatingX = !!translateX;
|
|
787
678
|
target.animatingY = !!translateY;
|
|
788
679
|
css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
|
|
@@ -802,11 +693,9 @@
|
|
|
802
693
|
}
|
|
803
694
|
};
|
|
804
695
|
}
|
|
805
|
-
|
|
806
696
|
function repaint(target) {
|
|
807
697
|
return target.offsetWidth;
|
|
808
698
|
}
|
|
809
|
-
|
|
810
699
|
function calculateRealTime(animatingRect, fromRect, toRect, options) {
|
|
811
700
|
return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
|
|
812
701
|
}
|
|
@@ -823,7 +712,6 @@
|
|
|
823
712
|
plugin[option] = defaults[option];
|
|
824
713
|
}
|
|
825
714
|
}
|
|
826
|
-
|
|
827
715
|
plugins.forEach(function (p) {
|
|
828
716
|
if (p.pluginName === plugin.pluginName) {
|
|
829
717
|
throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
|
|
@@ -833,25 +721,22 @@
|
|
|
833
721
|
},
|
|
834
722
|
pluginEvent: function pluginEvent(eventName, sortable, evt) {
|
|
835
723
|
var _this = this;
|
|
836
|
-
|
|
837
724
|
this.eventCanceled = false;
|
|
838
|
-
|
|
839
725
|
evt.cancel = function () {
|
|
840
726
|
_this.eventCanceled = true;
|
|
841
727
|
};
|
|
842
|
-
|
|
843
728
|
var eventNameGlobal = eventName + 'Global';
|
|
844
729
|
plugins.forEach(function (plugin) {
|
|
845
|
-
if (!sortable[plugin.pluginName]) return;
|
|
846
|
-
|
|
730
|
+
if (!sortable[plugin.pluginName]) return;
|
|
731
|
+
// Fire global events if it exists in this sortable
|
|
847
732
|
if (sortable[plugin.pluginName][eventNameGlobal]) {
|
|
848
733
|
sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
|
|
849
734
|
sortable: sortable
|
|
850
735
|
}, evt));
|
|
851
|
-
}
|
|
852
|
-
// and plugin has event defined
|
|
853
|
-
|
|
736
|
+
}
|
|
854
737
|
|
|
738
|
+
// Only fire plugin event if plugin is enabled in this sortable,
|
|
739
|
+
// and plugin has event defined
|
|
855
740
|
if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
|
|
856
741
|
sortable[plugin.pluginName][eventName](_objectSpread2({
|
|
857
742
|
sortable: sortable
|
|
@@ -866,15 +751,14 @@
|
|
|
866
751
|
var initialized = new plugin(sortable, el, sortable.options);
|
|
867
752
|
initialized.sortable = sortable;
|
|
868
753
|
initialized.options = sortable.options;
|
|
869
|
-
sortable[pluginName] = initialized;
|
|
754
|
+
sortable[pluginName] = initialized;
|
|
870
755
|
|
|
756
|
+
// Add default options from plugin
|
|
871
757
|
_extends(defaults, initialized.defaults);
|
|
872
758
|
});
|
|
873
|
-
|
|
874
759
|
for (var option in sortable.options) {
|
|
875
760
|
if (!sortable.options.hasOwnProperty(option)) continue;
|
|
876
761
|
var modified = this.modifyOption(sortable, option, sortable.options[option]);
|
|
877
|
-
|
|
878
762
|
if (typeof modified !== 'undefined') {
|
|
879
763
|
sortable.options[option] = modified;
|
|
880
764
|
}
|
|
@@ -884,7 +768,6 @@
|
|
|
884
768
|
var eventProperties = {};
|
|
885
769
|
plugins.forEach(function (plugin) {
|
|
886
770
|
if (typeof plugin.eventProperties !== 'function') return;
|
|
887
|
-
|
|
888
771
|
_extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
|
|
889
772
|
});
|
|
890
773
|
return eventProperties;
|
|
@@ -893,8 +776,9 @@
|
|
|
893
776
|
var modifiedValue;
|
|
894
777
|
plugins.forEach(function (plugin) {
|
|
895
778
|
// Plugin must exist on the Sortable
|
|
896
|
-
if (!sortable[plugin.pluginName]) return;
|
|
779
|
+
if (!sortable[plugin.pluginName]) return;
|
|
897
780
|
|
|
781
|
+
// If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
|
|
898
782
|
if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
|
|
899
783
|
modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
|
|
900
784
|
}
|
|
@@ -905,25 +789,25 @@
|
|
|
905
789
|
|
|
906
790
|
function dispatchEvent(_ref) {
|
|
907
791
|
var sortable = _ref.sortable,
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
792
|
+
rootEl = _ref.rootEl,
|
|
793
|
+
name = _ref.name,
|
|
794
|
+
targetEl = _ref.targetEl,
|
|
795
|
+
cloneEl = _ref.cloneEl,
|
|
796
|
+
toEl = _ref.toEl,
|
|
797
|
+
fromEl = _ref.fromEl,
|
|
798
|
+
oldIndex = _ref.oldIndex,
|
|
799
|
+
newIndex = _ref.newIndex,
|
|
800
|
+
oldDraggableIndex = _ref.oldDraggableIndex,
|
|
801
|
+
newDraggableIndex = _ref.newDraggableIndex,
|
|
802
|
+
originalEvent = _ref.originalEvent,
|
|
803
|
+
putSortable = _ref.putSortable,
|
|
804
|
+
extraEventProperties = _ref.extraEventProperties;
|
|
921
805
|
sortable = sortable || rootEl && rootEl[expando];
|
|
922
806
|
if (!sortable) return;
|
|
923
807
|
var evt,
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
808
|
+
options = sortable.options,
|
|
809
|
+
onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
|
|
810
|
+
// Support for new CustomEvent feature
|
|
927
811
|
if (window.CustomEvent && !IE11OrLess && !Edge) {
|
|
928
812
|
evt = new CustomEvent(name, {
|
|
929
813
|
bubbles: true,
|
|
@@ -933,7 +817,6 @@
|
|
|
933
817
|
evt = document.createEvent('Event');
|
|
934
818
|
evt.initEvent(name, true, true);
|
|
935
819
|
}
|
|
936
|
-
|
|
937
820
|
evt.to = toEl || rootEl;
|
|
938
821
|
evt.from = fromEl || rootEl;
|
|
939
822
|
evt.item = targetEl || rootEl;
|
|
@@ -944,29 +827,23 @@
|
|
|
944
827
|
evt.newDraggableIndex = newDraggableIndex;
|
|
945
828
|
evt.originalEvent = originalEvent;
|
|
946
829
|
evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
|
|
947
|
-
|
|
948
830
|
var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
|
|
949
|
-
|
|
950
831
|
for (var option in allEventProperties) {
|
|
951
832
|
evt[option] = allEventProperties[option];
|
|
952
833
|
}
|
|
953
|
-
|
|
954
834
|
if (rootEl) {
|
|
955
835
|
rootEl.dispatchEvent(evt);
|
|
956
836
|
}
|
|
957
|
-
|
|
958
837
|
if (options[onName]) {
|
|
959
838
|
options[onName].call(sortable, evt);
|
|
960
839
|
}
|
|
961
840
|
}
|
|
962
841
|
|
|
963
842
|
var _excluded = ["evt"];
|
|
964
|
-
|
|
965
843
|
var pluginEvent = function pluginEvent(eventName, sortable) {
|
|
966
844
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
845
|
+
originalEvent = _ref.evt,
|
|
846
|
+
data = _objectWithoutProperties(_ref, _excluded);
|
|
970
847
|
PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
|
|
971
848
|
dragEl: dragEl,
|
|
972
849
|
parentEl: parentEl,
|
|
@@ -1001,7 +878,6 @@
|
|
|
1001
878
|
}
|
|
1002
879
|
}, data));
|
|
1003
880
|
};
|
|
1004
|
-
|
|
1005
881
|
function _dispatchEvent(info) {
|
|
1006
882
|
dispatchEvent(_objectSpread2({
|
|
1007
883
|
putSortable: putSortable,
|
|
@@ -1014,62 +890,61 @@
|
|
|
1014
890
|
newDraggableIndex: newDraggableIndex
|
|
1015
891
|
}, info));
|
|
1016
892
|
}
|
|
1017
|
-
|
|
1018
893
|
var dragEl,
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
894
|
+
parentEl,
|
|
895
|
+
ghostEl,
|
|
896
|
+
rootEl,
|
|
897
|
+
nextEl,
|
|
898
|
+
lastDownEl,
|
|
899
|
+
cloneEl,
|
|
900
|
+
cloneHidden,
|
|
901
|
+
oldIndex,
|
|
902
|
+
newIndex,
|
|
903
|
+
oldDraggableIndex,
|
|
904
|
+
newDraggableIndex,
|
|
905
|
+
activeGroup,
|
|
906
|
+
putSortable,
|
|
907
|
+
awaitingDragStarted = false,
|
|
908
|
+
ignoreNextClick = false,
|
|
909
|
+
sortables = [],
|
|
910
|
+
tapEvt,
|
|
911
|
+
touchEvt,
|
|
912
|
+
lastDx,
|
|
913
|
+
lastDy,
|
|
914
|
+
tapDistanceLeft,
|
|
915
|
+
tapDistanceTop,
|
|
916
|
+
moved,
|
|
917
|
+
lastTarget,
|
|
918
|
+
lastDirection,
|
|
919
|
+
pastFirstInvertThresh = false,
|
|
920
|
+
isCircumstantialInvert = false,
|
|
921
|
+
targetMoveDistance,
|
|
922
|
+
// For positioning ghost absolutely
|
|
923
|
+
ghostRelativeParent,
|
|
924
|
+
ghostRelativeParentInitialScroll = [],
|
|
925
|
+
// (left, top)
|
|
926
|
+
|
|
927
|
+
_silent = false,
|
|
928
|
+
savedInputChecked = [];
|
|
1054
929
|
|
|
930
|
+
/** @const */
|
|
1055
931
|
var documentExists = typeof document !== 'undefined',
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
var elCSS = css(el),
|
|
932
|
+
PositionGhostAbsolutely = IOS,
|
|
933
|
+
CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
|
|
934
|
+
// This will not pass for IE9, because IE9 DnD only works on anchors
|
|
935
|
+
supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
|
|
936
|
+
supportCssPointerEvents = function () {
|
|
937
|
+
if (!documentExists) return;
|
|
938
|
+
// false when <= IE11
|
|
939
|
+
if (IE11OrLess) {
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
var el = document.createElement('x');
|
|
943
|
+
el.style.cssText = 'pointer-events:auto';
|
|
944
|
+
return el.style.pointerEvents === 'auto';
|
|
945
|
+
}(),
|
|
946
|
+
_detectDirection = function _detectDirection(el, options) {
|
|
947
|
+
var elCSS = css(el),
|
|
1073
948
|
elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
|
|
1074
949
|
child1 = getChild(el, 0, options),
|
|
1075
950
|
child2 = getChild(el, 1, options),
|
|
@@ -1077,103 +952,93 @@
|
|
|
1077
952
|
secondChildCSS = child2 && css(child2),
|
|
1078
953
|
firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
|
|
1079
954
|
secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
|
|
1095
|
-
},
|
|
1096
|
-
_dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
|
|
1097
|
-
var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
|
|
955
|
+
if (elCSS.display === 'flex') {
|
|
956
|
+
return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
|
|
957
|
+
}
|
|
958
|
+
if (elCSS.display === 'grid') {
|
|
959
|
+
return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
|
|
960
|
+
}
|
|
961
|
+
if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
|
|
962
|
+
var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
|
|
963
|
+
return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
|
|
964
|
+
}
|
|
965
|
+
return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
|
|
966
|
+
},
|
|
967
|
+
_dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
|
|
968
|
+
var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
|
|
1098
969
|
dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
|
|
1099
970
|
dragElOppLength = vertical ? dragRect.width : dragRect.height,
|
|
1100
971
|
targetS1Opp = vertical ? targetRect.left : targetRect.top,
|
|
1101
972
|
targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
|
|
1102
973
|
targetOppLength = vertical ? targetRect.width : targetRect.height;
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
var rect = getRect(sortable),
|
|
974
|
+
return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
|
|
975
|
+
},
|
|
976
|
+
/**
|
|
977
|
+
* Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
|
|
978
|
+
* @param {Number} x X position
|
|
979
|
+
* @param {Number} y Y position
|
|
980
|
+
* @return {HTMLElement} Element of the first found nearest Sortable
|
|
981
|
+
*/
|
|
982
|
+
_detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
|
|
983
|
+
var ret;
|
|
984
|
+
sortables.some(function (sortable) {
|
|
985
|
+
var threshold = sortable[expando].options.emptyInsertThreshold;
|
|
986
|
+
if (!threshold || lastChild(sortable)) return;
|
|
987
|
+
var rect = getRect(sortable),
|
|
1118
988
|
insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
|
|
1119
989
|
insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
return ret = sortable;
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
return ret;
|
|
1126
|
-
},
|
|
1127
|
-
_prepareGroup = function _prepareGroup(options) {
|
|
1128
|
-
function toFn(value, pull) {
|
|
1129
|
-
return function (to, from, dragEl, evt) {
|
|
1130
|
-
var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
|
|
1131
|
-
|
|
1132
|
-
if (value == null && (pull || sameGroup)) {
|
|
1133
|
-
// Default pull value
|
|
1134
|
-
// Default pull and put value if same group
|
|
1135
|
-
return true;
|
|
1136
|
-
} else if (value == null || value === false) {
|
|
1137
|
-
return false;
|
|
1138
|
-
} else if (pull && value === 'clone') {
|
|
1139
|
-
return value;
|
|
1140
|
-
} else if (typeof value === 'function') {
|
|
1141
|
-
return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
|
|
1142
|
-
} else {
|
|
1143
|
-
var otherGroup = (pull ? to : from).options.group.name;
|
|
1144
|
-
return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
|
|
990
|
+
if (insideHorizontally && insideVertically) {
|
|
991
|
+
return ret = sortable;
|
|
1145
992
|
}
|
|
1146
|
-
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
993
|
+
});
|
|
994
|
+
return ret;
|
|
995
|
+
},
|
|
996
|
+
_prepareGroup = function _prepareGroup(options) {
|
|
997
|
+
function toFn(value, pull) {
|
|
998
|
+
return function (to, from, dragEl, evt) {
|
|
999
|
+
var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
|
|
1000
|
+
if (value == null && (pull || sameGroup)) {
|
|
1001
|
+
// Default pull value
|
|
1002
|
+
// Default pull and put value if same group
|
|
1003
|
+
return true;
|
|
1004
|
+
} else if (value == null || value === false) {
|
|
1005
|
+
return false;
|
|
1006
|
+
} else if (pull && value === 'clone') {
|
|
1007
|
+
return value;
|
|
1008
|
+
} else if (typeof value === 'function') {
|
|
1009
|
+
return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
|
|
1010
|
+
} else {
|
|
1011
|
+
var otherGroup = (pull ? to : from).options.group.name;
|
|
1012
|
+
return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
var group = {};
|
|
1017
|
+
var originalGroup = options.group;
|
|
1018
|
+
if (!originalGroup || _typeof(originalGroup) != 'object') {
|
|
1019
|
+
originalGroup = {
|
|
1020
|
+
name: originalGroup
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
group.name = originalGroup.name;
|
|
1024
|
+
group.checkPull = toFn(originalGroup.pull, true);
|
|
1025
|
+
group.checkPut = toFn(originalGroup.put);
|
|
1026
|
+
group.revertClone = originalGroup.revertClone;
|
|
1027
|
+
options.group = group;
|
|
1028
|
+
},
|
|
1029
|
+
_hideGhostForTarget = function _hideGhostForTarget() {
|
|
1030
|
+
if (!supportCssPointerEvents && ghostEl) {
|
|
1031
|
+
css(ghostEl, 'display', 'none');
|
|
1032
|
+
}
|
|
1033
|
+
},
|
|
1034
|
+
_unhideGhostForTarget = function _unhideGhostForTarget() {
|
|
1035
|
+
if (!supportCssPointerEvents && ghostEl) {
|
|
1036
|
+
css(ghostEl, 'display', '');
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1175
1039
|
|
|
1176
|
-
if
|
|
1040
|
+
// #1184 fix - Prevent click event on fallback if dragged but item not changed position
|
|
1041
|
+
if (documentExists && !ChromeForAndroid) {
|
|
1177
1042
|
document.addEventListener('click', function (evt) {
|
|
1178
1043
|
if (ignoreNextClick) {
|
|
1179
1044
|
evt.preventDefault();
|
|
@@ -1184,53 +1049,44 @@
|
|
|
1184
1049
|
}
|
|
1185
1050
|
}, true);
|
|
1186
1051
|
}
|
|
1187
|
-
|
|
1188
1052
|
var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
|
|
1189
1053
|
if (dragEl) {
|
|
1190
1054
|
evt = evt.touches ? evt.touches[0] : evt;
|
|
1191
|
-
|
|
1192
1055
|
var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
|
|
1193
|
-
|
|
1194
1056
|
if (nearest) {
|
|
1195
1057
|
// Create imitation event
|
|
1196
1058
|
var event = {};
|
|
1197
|
-
|
|
1198
1059
|
for (var i in evt) {
|
|
1199
1060
|
if (evt.hasOwnProperty(i)) {
|
|
1200
1061
|
event[i] = evt[i];
|
|
1201
1062
|
}
|
|
1202
1063
|
}
|
|
1203
|
-
|
|
1204
1064
|
event.target = event.rootEl = nearest;
|
|
1205
1065
|
event.preventDefault = void 0;
|
|
1206
1066
|
event.stopPropagation = void 0;
|
|
1207
|
-
|
|
1208
1067
|
nearest[expando]._onDragOver(event);
|
|
1209
1068
|
}
|
|
1210
1069
|
}
|
|
1211
1070
|
};
|
|
1212
|
-
|
|
1213
1071
|
var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
|
|
1214
1072
|
if (dragEl) {
|
|
1215
1073
|
dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
|
|
1216
1074
|
}
|
|
1217
1075
|
};
|
|
1218
|
-
/**
|
|
1219
|
-
* @class Sortable
|
|
1220
|
-
* @param {HTMLElement} el
|
|
1221
|
-
* @param {Object} [options]
|
|
1222
|
-
*/
|
|
1223
|
-
|
|
1224
1076
|
|
|
1077
|
+
/**
|
|
1078
|
+
* @class Sortable
|
|
1079
|
+
* @param {HTMLElement} el
|
|
1080
|
+
* @param {Object} [options]
|
|
1081
|
+
*/
|
|
1225
1082
|
function Sortable(el, options) {
|
|
1226
1083
|
if (!(el && el.nodeType && el.nodeType === 1)) {
|
|
1227
1084
|
throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
|
|
1228
1085
|
}
|
|
1229
|
-
|
|
1230
1086
|
this.el = el; // root element
|
|
1087
|
+
this.options = options = _extends({}, options);
|
|
1231
1088
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1089
|
+
// Export instance
|
|
1234
1090
|
el[expando] = this;
|
|
1235
1091
|
var defaults = {
|
|
1236
1092
|
group: null,
|
|
@@ -1277,52 +1133,48 @@
|
|
|
1277
1133
|
supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && !Safari,
|
|
1278
1134
|
emptyInsertThreshold: 5
|
|
1279
1135
|
};
|
|
1280
|
-
PluginManager.initializePlugins(this, el, defaults);
|
|
1136
|
+
PluginManager.initializePlugins(this, el, defaults);
|
|
1281
1137
|
|
|
1138
|
+
// Set default options
|
|
1282
1139
|
for (var name in defaults) {
|
|
1283
1140
|
!(name in options) && (options[name] = defaults[name]);
|
|
1284
1141
|
}
|
|
1142
|
+
_prepareGroup(options);
|
|
1285
1143
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1144
|
+
// Bind all private methods
|
|
1289
1145
|
for (var fn in this) {
|
|
1290
1146
|
if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
|
|
1291
1147
|
this[fn] = this[fn].bind(this);
|
|
1292
1148
|
}
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1149
|
+
}
|
|
1295
1150
|
|
|
1151
|
+
// Setup drag mode
|
|
1296
1152
|
this.nativeDraggable = options.forceFallback ? false : supportDraggable;
|
|
1297
|
-
|
|
1298
1153
|
if (this.nativeDraggable) {
|
|
1299
1154
|
// Touch start threshold cannot be greater than the native dragstart threshold
|
|
1300
1155
|
this.options.touchStartThreshold = 1;
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1156
|
+
}
|
|
1303
1157
|
|
|
1158
|
+
// Bind events
|
|
1304
1159
|
if (options.supportPointer) {
|
|
1305
1160
|
on(el, 'pointerdown', this._onTapStart);
|
|
1306
1161
|
} else {
|
|
1307
1162
|
on(el, 'mousedown', this._onTapStart);
|
|
1308
1163
|
on(el, 'touchstart', this._onTapStart);
|
|
1309
1164
|
}
|
|
1310
|
-
|
|
1311
1165
|
if (this.nativeDraggable) {
|
|
1312
1166
|
on(el, 'dragover', this);
|
|
1313
1167
|
on(el, 'dragenter', this);
|
|
1314
1168
|
}
|
|
1169
|
+
sortables.push(this.el);
|
|
1315
1170
|
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
options.store && options.store.get && this.sort(options.store.get(this) || []); // Add animation state manager
|
|
1171
|
+
// Restore sorting
|
|
1172
|
+
options.store && options.store.get && this.sort(options.store.get(this) || []);
|
|
1319
1173
|
|
|
1174
|
+
// Add animation state manager
|
|
1320
1175
|
_extends(this, AnimationStateManager());
|
|
1321
1176
|
}
|
|
1322
|
-
|
|
1323
|
-
Sortable.prototype =
|
|
1324
|
-
/** @lends Sortable.prototype */
|
|
1325
|
-
{
|
|
1177
|
+
Sortable.prototype = /** @lends Sortable.prototype */{
|
|
1326
1178
|
constructor: Sortable,
|
|
1327
1179
|
_isOutsideThisEl: function _isOutsideThisEl(target) {
|
|
1328
1180
|
if (!this.el.contains(target) && target !== this.el) {
|
|
@@ -1332,57 +1184,50 @@
|
|
|
1332
1184
|
_getDirection: function _getDirection(evt, target) {
|
|
1333
1185
|
return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
|
|
1334
1186
|
},
|
|
1335
|
-
_onTapStart: function _onTapStart(
|
|
1336
|
-
/** Event|TouchEvent */
|
|
1337
|
-
evt) {
|
|
1187
|
+
_onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
|
|
1338
1188
|
if (!evt.cancelable) return;
|
|
1339
|
-
|
|
1340
1189
|
var _this = this,
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1190
|
+
el = this.el,
|
|
1191
|
+
options = this.options,
|
|
1192
|
+
preventOnFilter = options.preventOnFilter,
|
|
1193
|
+
type = evt.type,
|
|
1194
|
+
touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
|
|
1195
|
+
target = (touch || evt).target,
|
|
1196
|
+
originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
|
|
1197
|
+
filter = options.filter;
|
|
1198
|
+
_saveInputCheckedState(el);
|
|
1199
|
+
|
|
1200
|
+
// Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
|
|
1353
1201
|
if (dragEl) {
|
|
1354
1202
|
return;
|
|
1355
1203
|
}
|
|
1356
|
-
|
|
1357
1204
|
if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
|
|
1358
1205
|
return; // only left button and enabled
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1206
|
+
}
|
|
1361
1207
|
|
|
1208
|
+
// cancel dnd if original target is content editable
|
|
1362
1209
|
if (originalTarget.isContentEditable) {
|
|
1363
1210
|
return;
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1211
|
+
}
|
|
1366
1212
|
|
|
1213
|
+
// Safari ignores further event handling after mousedown
|
|
1367
1214
|
if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
|
|
1368
1215
|
return;
|
|
1369
1216
|
}
|
|
1370
|
-
|
|
1371
1217
|
target = closest(target, options.draggable, el, false);
|
|
1372
|
-
|
|
1373
1218
|
if (target && target.animated) {
|
|
1374
1219
|
return;
|
|
1375
1220
|
}
|
|
1376
|
-
|
|
1377
1221
|
if (lastDownEl === target) {
|
|
1378
1222
|
// Ignoring duplicate `down`
|
|
1379
1223
|
return;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1224
|
+
}
|
|
1382
1225
|
|
|
1226
|
+
// Get the index of the dragged element within its parent
|
|
1383
1227
|
oldIndex = index(target);
|
|
1384
|
-
oldDraggableIndex = index(target, options.draggable);
|
|
1228
|
+
oldDraggableIndex = index(target, options.draggable);
|
|
1385
1229
|
|
|
1230
|
+
// Check filter
|
|
1386
1231
|
if (typeof filter === 'function') {
|
|
1387
1232
|
if (filter.call(this, evt, target, this)) {
|
|
1388
1233
|
_dispatchEvent({
|
|
@@ -1393,7 +1238,6 @@
|
|
|
1393
1238
|
toEl: el,
|
|
1394
1239
|
fromEl: el
|
|
1395
1240
|
});
|
|
1396
|
-
|
|
1397
1241
|
pluginEvent('filter', _this, {
|
|
1398
1242
|
evt: evt
|
|
1399
1243
|
});
|
|
@@ -1403,7 +1247,6 @@
|
|
|
1403
1247
|
} else if (filter) {
|
|
1404
1248
|
filter = filter.split(',').some(function (criteria) {
|
|
1405
1249
|
criteria = closest(originalTarget, criteria.trim(), el, false);
|
|
1406
|
-
|
|
1407
1250
|
if (criteria) {
|
|
1408
1251
|
_dispatchEvent({
|
|
1409
1252
|
sortable: _this,
|
|
@@ -1413,40 +1256,30 @@
|
|
|
1413
1256
|
fromEl: el,
|
|
1414
1257
|
toEl: el
|
|
1415
1258
|
});
|
|
1416
|
-
|
|
1417
1259
|
pluginEvent('filter', _this, {
|
|
1418
1260
|
evt: evt
|
|
1419
1261
|
});
|
|
1420
1262
|
return true;
|
|
1421
1263
|
}
|
|
1422
1264
|
});
|
|
1423
|
-
|
|
1424
1265
|
if (filter) {
|
|
1425
1266
|
preventOnFilter && evt.cancelable && evt.preventDefault();
|
|
1426
1267
|
return; // cancel dnd
|
|
1427
1268
|
}
|
|
1428
1269
|
}
|
|
1429
|
-
|
|
1430
1270
|
if (options.handle && !closest(originalTarget, options.handle, el, false)) {
|
|
1431
1271
|
return;
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1272
|
+
}
|
|
1434
1273
|
|
|
1274
|
+
// Prepare `dragstart`
|
|
1435
1275
|
this._prepareDragStart(evt, touch, target);
|
|
1436
1276
|
},
|
|
1437
|
-
_prepareDragStart: function _prepareDragStart(
|
|
1438
|
-
/** Event */
|
|
1439
|
-
evt,
|
|
1440
|
-
/** Touch */
|
|
1441
|
-
touch,
|
|
1442
|
-
/** HTMLElement */
|
|
1443
|
-
target) {
|
|
1277
|
+
_prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) {
|
|
1444
1278
|
var _this = this,
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1279
|
+
el = _this.el,
|
|
1280
|
+
options = _this.options,
|
|
1281
|
+
ownerDocument = el.ownerDocument,
|
|
1282
|
+
dragStartFn;
|
|
1450
1283
|
if (target && !dragEl && target.parentNode === el) {
|
|
1451
1284
|
var dragRect = getRect(target);
|
|
1452
1285
|
rootEl = el;
|
|
@@ -1466,41 +1299,36 @@
|
|
|
1466
1299
|
this._lastX = (touch || evt).clientX;
|
|
1467
1300
|
this._lastY = (touch || evt).clientY;
|
|
1468
1301
|
dragEl.style['will-change'] = 'all';
|
|
1469
|
-
|
|
1470
1302
|
dragStartFn = function dragStartFn() {
|
|
1471
1303
|
pluginEvent('delayEnded', _this, {
|
|
1472
1304
|
evt: evt
|
|
1473
1305
|
});
|
|
1474
|
-
|
|
1475
1306
|
if (Sortable.eventCanceled) {
|
|
1476
1307
|
_this._onDrop();
|
|
1477
|
-
|
|
1478
1308
|
return;
|
|
1479
|
-
}
|
|
1309
|
+
}
|
|
1310
|
+
// Delayed drag has been triggered
|
|
1480
1311
|
// we can re-enable the events: touchmove/mousemove
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
1312
|
_this._disableDelayedDragEvents();
|
|
1484
|
-
|
|
1485
1313
|
if (!FireFox && _this.nativeDraggable) {
|
|
1486
1314
|
dragEl.draggable = true;
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
_this._triggerDragStart(evt, touch); // Drag start event
|
|
1315
|
+
}
|
|
1491
1316
|
|
|
1317
|
+
// Bind the events: dragstart/dragend
|
|
1318
|
+
_this._triggerDragStart(evt, touch);
|
|
1492
1319
|
|
|
1320
|
+
// Drag start event
|
|
1493
1321
|
_dispatchEvent({
|
|
1494
1322
|
sortable: _this,
|
|
1495
1323
|
name: 'choose',
|
|
1496
1324
|
originalEvent: evt
|
|
1497
|
-
});
|
|
1498
|
-
|
|
1325
|
+
});
|
|
1499
1326
|
|
|
1327
|
+
// Chosen item
|
|
1500
1328
|
toggleClass(dragEl, options.chosenClass, true);
|
|
1501
|
-
};
|
|
1502
|
-
|
|
1329
|
+
};
|
|
1503
1330
|
|
|
1331
|
+
// Disable "draggable"
|
|
1504
1332
|
options.ignore.split(',').forEach(function (criteria) {
|
|
1505
1333
|
find(dragEl, criteria.trim(), _disableDraggable);
|
|
1506
1334
|
});
|
|
@@ -1509,27 +1337,26 @@
|
|
|
1509
1337
|
on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
|
|
1510
1338
|
on(ownerDocument, 'mouseup', _this._onDrop);
|
|
1511
1339
|
on(ownerDocument, 'touchend', _this._onDrop);
|
|
1512
|
-
on(ownerDocument, 'touchcancel', _this._onDrop);
|
|
1340
|
+
on(ownerDocument, 'touchcancel', _this._onDrop);
|
|
1513
1341
|
|
|
1342
|
+
// Make dragEl draggable (must be before delay for FireFox)
|
|
1514
1343
|
if (FireFox && this.nativeDraggable) {
|
|
1515
1344
|
this.options.touchStartThreshold = 4;
|
|
1516
1345
|
dragEl.draggable = true;
|
|
1517
1346
|
}
|
|
1518
|
-
|
|
1519
1347
|
pluginEvent('delayStart', this, {
|
|
1520
1348
|
evt: evt
|
|
1521
|
-
});
|
|
1349
|
+
});
|
|
1522
1350
|
|
|
1351
|
+
// Delay is impossible for native DnD in Edge or IE
|
|
1523
1352
|
if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
|
|
1524
1353
|
if (Sortable.eventCanceled) {
|
|
1525
1354
|
this._onDrop();
|
|
1526
|
-
|
|
1527
1355
|
return;
|
|
1528
|
-
}
|
|
1356
|
+
}
|
|
1357
|
+
// If the user moves the pointer or let go the click or touch
|
|
1529
1358
|
// before the delay has been reached:
|
|
1530
1359
|
// disable the delayed drag
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
1360
|
on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
|
|
1534
1361
|
on(ownerDocument, 'touchend', _this._disableDelayedDrag);
|
|
1535
1362
|
on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
|
|
@@ -1542,11 +1369,8 @@
|
|
|
1542
1369
|
}
|
|
1543
1370
|
}
|
|
1544
1371
|
},
|
|
1545
|
-
_delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(
|
|
1546
|
-
/** TouchEvent|PointerEvent **/
|
|
1547
|
-
e) {
|
|
1372
|
+
_delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) {
|
|
1548
1373
|
var touch = e.touches ? e.touches[0] : e;
|
|
1549
|
-
|
|
1550
1374
|
if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
|
|
1551
1375
|
this._disableDelayedDrag();
|
|
1552
1376
|
}
|
|
@@ -1554,7 +1378,6 @@
|
|
|
1554
1378
|
_disableDelayedDrag: function _disableDelayedDrag() {
|
|
1555
1379
|
dragEl && _disableDraggable(dragEl);
|
|
1556
1380
|
clearTimeout(this._dragStartTimer);
|
|
1557
|
-
|
|
1558
1381
|
this._disableDelayedDragEvents();
|
|
1559
1382
|
},
|
|
1560
1383
|
_disableDelayedDragEvents: function _disableDelayedDragEvents() {
|
|
@@ -1566,13 +1389,8 @@
|
|
|
1566
1389
|
off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
|
|
1567
1390
|
off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
|
|
1568
1391
|
},
|
|
1569
|
-
_triggerDragStart: function _triggerDragStart(
|
|
1570
|
-
/** Event */
|
|
1571
|
-
evt,
|
|
1572
|
-
/** Touch */
|
|
1573
|
-
touch) {
|
|
1392
|
+
_triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
|
|
1574
1393
|
touch = touch || evt.pointerType == 'touch' && evt;
|
|
1575
|
-
|
|
1576
1394
|
if (!this.nativeDraggable || touch) {
|
|
1577
1395
|
if (this.options.supportPointer) {
|
|
1578
1396
|
on(document, 'pointermove', this._onTouchMove);
|
|
@@ -1585,7 +1403,6 @@
|
|
|
1585
1403
|
on(dragEl, 'dragend', this);
|
|
1586
1404
|
on(rootEl, 'dragstart', this._onDragStart);
|
|
1587
1405
|
}
|
|
1588
|
-
|
|
1589
1406
|
try {
|
|
1590
1407
|
if (document.selection) {
|
|
1591
1408
|
// Timeout neccessary for IE9
|
|
@@ -1598,25 +1415,23 @@
|
|
|
1598
1415
|
} catch (err) {}
|
|
1599
1416
|
},
|
|
1600
1417
|
_dragStarted: function _dragStarted(fallback, evt) {
|
|
1601
|
-
|
|
1602
1418
|
awaitingDragStarted = false;
|
|
1603
|
-
|
|
1604
1419
|
if (rootEl && dragEl) {
|
|
1605
1420
|
pluginEvent('dragStarted', this, {
|
|
1606
1421
|
evt: evt
|
|
1607
1422
|
});
|
|
1608
|
-
|
|
1609
1423
|
if (this.nativeDraggable) {
|
|
1610
1424
|
on(document, 'dragover', _checkOutsideTargetEl);
|
|
1611
1425
|
}
|
|
1426
|
+
var options = this.options;
|
|
1612
1427
|
|
|
1613
|
-
|
|
1614
|
-
|
|
1428
|
+
// Apply effect
|
|
1615
1429
|
!fallback && toggleClass(dragEl, options.dragClass, false);
|
|
1616
1430
|
toggleClass(dragEl, options.ghostClass, true);
|
|
1617
1431
|
Sortable.active = this;
|
|
1618
|
-
fallback && this._appendGhost();
|
|
1432
|
+
fallback && this._appendGhost();
|
|
1619
1433
|
|
|
1434
|
+
// Drag start event
|
|
1620
1435
|
_dispatchEvent({
|
|
1621
1436
|
sortable: this,
|
|
1622
1437
|
name: 'start',
|
|
@@ -1630,20 +1445,15 @@
|
|
|
1630
1445
|
if (touchEvt) {
|
|
1631
1446
|
this._lastX = touchEvt.clientX;
|
|
1632
1447
|
this._lastY = touchEvt.clientY;
|
|
1633
|
-
|
|
1634
1448
|
_hideGhostForTarget();
|
|
1635
|
-
|
|
1636
1449
|
var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
|
|
1637
1450
|
var parent = target;
|
|
1638
|
-
|
|
1639
1451
|
while (target && target.shadowRoot) {
|
|
1640
1452
|
target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
|
|
1641
1453
|
if (target === parent) break;
|
|
1642
1454
|
parent = target;
|
|
1643
1455
|
}
|
|
1644
|
-
|
|
1645
1456
|
dragEl.parentNode[expando]._isOutsideThisEl(target);
|
|
1646
|
-
|
|
1647
1457
|
if (parent) {
|
|
1648
1458
|
do {
|
|
1649
1459
|
if (parent[expando]) {
|
|
@@ -1654,44 +1464,37 @@
|
|
|
1654
1464
|
target: target,
|
|
1655
1465
|
rootEl: parent
|
|
1656
1466
|
});
|
|
1657
|
-
|
|
1658
1467
|
if (inserted && !this.options.dragoverBubble) {
|
|
1659
1468
|
break;
|
|
1660
1469
|
}
|
|
1661
1470
|
}
|
|
1662
|
-
|
|
1663
1471
|
target = parent; // store last element
|
|
1664
1472
|
}
|
|
1665
|
-
/* jshint boss:true */
|
|
1666
|
-
while (parent = parent.parentNode);
|
|
1473
|
+
/* jshint boss:true */ while (parent = parent.parentNode);
|
|
1667
1474
|
}
|
|
1668
|
-
|
|
1669
1475
|
_unhideGhostForTarget();
|
|
1670
1476
|
}
|
|
1671
1477
|
},
|
|
1672
|
-
_onTouchMove: function _onTouchMove(
|
|
1673
|
-
/**TouchEvent*/
|
|
1674
|
-
evt) {
|
|
1478
|
+
_onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
|
|
1675
1479
|
if (tapEvt) {
|
|
1676
1480
|
var options = this.options,
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1481
|
+
fallbackTolerance = options.fallbackTolerance,
|
|
1482
|
+
fallbackOffset = options.fallbackOffset,
|
|
1483
|
+
touch = evt.touches ? evt.touches[0] : evt,
|
|
1484
|
+
ghostMatrix = ghostEl && matrix(ghostEl, true),
|
|
1485
|
+
scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
|
|
1486
|
+
scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
|
|
1487
|
+
relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
|
|
1488
|
+
dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
|
|
1489
|
+
dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
|
|
1490
|
+
|
|
1491
|
+
// only set the status to dragging, when we are actually dragging
|
|
1687
1492
|
if (!Sortable.active && !awaitingDragStarted) {
|
|
1688
1493
|
if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
|
|
1689
1494
|
return;
|
|
1690
1495
|
}
|
|
1691
|
-
|
|
1692
1496
|
this._onDragStart(evt, true);
|
|
1693
1497
|
}
|
|
1694
|
-
|
|
1695
1498
|
if (ghostEl) {
|
|
1696
1499
|
if (ghostMatrix) {
|
|
1697
1500
|
ghostMatrix.e += dx - (lastDx || 0);
|
|
@@ -1706,7 +1509,6 @@
|
|
|
1706
1509
|
f: dy
|
|
1707
1510
|
};
|
|
1708
1511
|
}
|
|
1709
|
-
|
|
1710
1512
|
var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
|
|
1711
1513
|
css(ghostEl, 'webkitTransform', cssMatrix);
|
|
1712
1514
|
css(ghostEl, 'mozTransform', cssMatrix);
|
|
@@ -1716,7 +1518,6 @@
|
|
|
1716
1518
|
lastDy = dy;
|
|
1717
1519
|
touchEvt = touch;
|
|
1718
1520
|
}
|
|
1719
|
-
|
|
1720
1521
|
evt.cancelable && evt.preventDefault();
|
|
1721
1522
|
}
|
|
1722
1523
|
},
|
|
@@ -1725,17 +1526,16 @@
|
|
|
1725
1526
|
// Not being adjusted for
|
|
1726
1527
|
if (!ghostEl) {
|
|
1727
1528
|
var container = this.options.fallbackOnBody ? document.body : rootEl,
|
|
1728
|
-
|
|
1729
|
-
|
|
1529
|
+
rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
|
|
1530
|
+
options = this.options;
|
|
1730
1531
|
|
|
1532
|
+
// Position absolutely
|
|
1731
1533
|
if (PositionGhostAbsolutely) {
|
|
1732
1534
|
// Get relatively positioned parent
|
|
1733
1535
|
ghostRelativeParent = container;
|
|
1734
|
-
|
|
1735
1536
|
while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
|
|
1736
1537
|
ghostRelativeParent = ghostRelativeParent.parentNode;
|
|
1737
1538
|
}
|
|
1738
|
-
|
|
1739
1539
|
if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
|
|
1740
1540
|
if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
|
|
1741
1541
|
rect.top += ghostRelativeParent.scrollTop;
|
|
@@ -1743,10 +1543,8 @@
|
|
|
1743
1543
|
} else {
|
|
1744
1544
|
ghostRelativeParent = getWindowScrollingElement();
|
|
1745
1545
|
}
|
|
1746
|
-
|
|
1747
1546
|
ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
|
|
1748
1547
|
}
|
|
1749
|
-
|
|
1750
1548
|
ghostEl = dragEl.cloneNode(true);
|
|
1751
1549
|
toggleClass(ghostEl, options.ghostClass, false);
|
|
1752
1550
|
toggleClass(ghostEl, options.fallbackClass, true);
|
|
@@ -1764,61 +1562,50 @@
|
|
|
1764
1562
|
css(ghostEl, 'zIndex', '100000');
|
|
1765
1563
|
css(ghostEl, 'pointerEvents', 'none');
|
|
1766
1564
|
Sortable.ghost = ghostEl;
|
|
1767
|
-
container.appendChild(ghostEl);
|
|
1565
|
+
container.appendChild(ghostEl);
|
|
1768
1566
|
|
|
1567
|
+
// Set transform-origin
|
|
1769
1568
|
css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
|
|
1770
1569
|
}
|
|
1771
1570
|
},
|
|
1772
|
-
_onDragStart: function _onDragStart(
|
|
1773
|
-
/**Event*/
|
|
1774
|
-
evt,
|
|
1775
|
-
/**boolean*/
|
|
1776
|
-
fallback) {
|
|
1571
|
+
_onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) {
|
|
1777
1572
|
var _this = this;
|
|
1778
|
-
|
|
1779
1573
|
var dataTransfer = evt.dataTransfer;
|
|
1780
1574
|
var options = _this.options;
|
|
1781
1575
|
pluginEvent('dragStart', this, {
|
|
1782
1576
|
evt: evt
|
|
1783
1577
|
});
|
|
1784
|
-
|
|
1785
1578
|
if (Sortable.eventCanceled) {
|
|
1786
1579
|
this._onDrop();
|
|
1787
|
-
|
|
1788
1580
|
return;
|
|
1789
1581
|
}
|
|
1790
|
-
|
|
1791
1582
|
pluginEvent('setupClone', this);
|
|
1792
|
-
|
|
1793
1583
|
if (!Sortable.eventCanceled) {
|
|
1794
1584
|
cloneEl = clone(dragEl);
|
|
1585
|
+
cloneEl.removeAttribute("id");
|
|
1795
1586
|
cloneEl.draggable = false;
|
|
1796
1587
|
cloneEl.style['will-change'] = '';
|
|
1797
|
-
|
|
1798
1588
|
this._hideClone();
|
|
1799
|
-
|
|
1800
1589
|
toggleClass(cloneEl, this.options.chosenClass, false);
|
|
1801
1590
|
Sortable.clone = cloneEl;
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1591
|
+
}
|
|
1804
1592
|
|
|
1593
|
+
// #1143: IFrame support workaround
|
|
1805
1594
|
_this.cloneId = _nextTick(function () {
|
|
1806
1595
|
pluginEvent('clone', _this);
|
|
1807
1596
|
if (Sortable.eventCanceled) return;
|
|
1808
|
-
|
|
1809
1597
|
if (!_this.options.removeCloneOnHide) {
|
|
1810
1598
|
rootEl.insertBefore(cloneEl, dragEl);
|
|
1811
1599
|
}
|
|
1812
|
-
|
|
1813
1600
|
_this._hideClone();
|
|
1814
|
-
|
|
1815
1601
|
_dispatchEvent({
|
|
1816
1602
|
sortable: _this,
|
|
1817
1603
|
name: 'clone'
|
|
1818
1604
|
});
|
|
1819
1605
|
});
|
|
1820
|
-
!fallback && toggleClass(dragEl, options.dragClass, true);
|
|
1606
|
+
!fallback && toggleClass(dragEl, options.dragClass, true);
|
|
1821
1607
|
|
|
1608
|
+
// Set proper drop events
|
|
1822
1609
|
if (fallback) {
|
|
1823
1610
|
ignoreNextClick = true;
|
|
1824
1611
|
_this._loopId = setInterval(_this._emulateDragOver, 50);
|
|
@@ -1827,47 +1614,40 @@
|
|
|
1827
1614
|
off(document, 'mouseup', _this._onDrop);
|
|
1828
1615
|
off(document, 'touchend', _this._onDrop);
|
|
1829
1616
|
off(document, 'touchcancel', _this._onDrop);
|
|
1830
|
-
|
|
1831
1617
|
if (dataTransfer) {
|
|
1832
1618
|
dataTransfer.effectAllowed = 'move';
|
|
1833
1619
|
options.setData && options.setData.call(_this, dataTransfer, dragEl);
|
|
1834
1620
|
}
|
|
1621
|
+
on(document, 'drop', _this);
|
|
1835
1622
|
|
|
1836
|
-
|
|
1837
|
-
|
|
1623
|
+
// #1276 fix:
|
|
1838
1624
|
css(dragEl, 'transform', 'translateZ(0)');
|
|
1839
1625
|
}
|
|
1840
|
-
|
|
1841
1626
|
awaitingDragStarted = true;
|
|
1842
1627
|
_this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
|
|
1843
1628
|
on(document, 'selectstart', _this);
|
|
1844
1629
|
moved = true;
|
|
1845
|
-
|
|
1846
1630
|
if (Safari) {
|
|
1847
1631
|
css(document.body, 'user-select', 'none');
|
|
1848
1632
|
}
|
|
1849
1633
|
},
|
|
1850
1634
|
// Returns true - if no further action is needed (either inserted or another condition)
|
|
1851
|
-
_onDragOver: function _onDragOver(
|
|
1852
|
-
/**Event*/
|
|
1853
|
-
evt) {
|
|
1635
|
+
_onDragOver: function _onDragOver( /**Event*/evt) {
|
|
1854
1636
|
var el = this.el,
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1637
|
+
target = evt.target,
|
|
1638
|
+
dragRect,
|
|
1639
|
+
targetRect,
|
|
1640
|
+
revert,
|
|
1641
|
+
options = this.options,
|
|
1642
|
+
group = options.group,
|
|
1643
|
+
activeSortable = Sortable.active,
|
|
1644
|
+
isOwner = activeGroup === group,
|
|
1645
|
+
canSort = options.sort,
|
|
1646
|
+
fromSortable = putSortable || activeSortable,
|
|
1647
|
+
vertical,
|
|
1648
|
+
_this = this,
|
|
1649
|
+
completedFired = false;
|
|
1869
1650
|
if (_silent) return;
|
|
1870
|
-
|
|
1871
1651
|
function dragOverEvent(name, extra) {
|
|
1872
1652
|
pluginEvent(name, _this, _objectSpread2({
|
|
1873
1653
|
evt: evt,
|
|
@@ -1885,25 +1665,22 @@
|
|
|
1885
1665
|
},
|
|
1886
1666
|
changed: changed
|
|
1887
1667
|
}, extra));
|
|
1888
|
-
}
|
|
1889
|
-
|
|
1668
|
+
}
|
|
1890
1669
|
|
|
1670
|
+
// Capture animation state
|
|
1891
1671
|
function capture() {
|
|
1892
1672
|
dragOverEvent('dragOverAnimationCapture');
|
|
1893
|
-
|
|
1894
1673
|
_this.captureAnimationState();
|
|
1895
|
-
|
|
1896
1674
|
if (_this !== fromSortable) {
|
|
1897
1675
|
fromSortable.captureAnimationState();
|
|
1898
1676
|
}
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1677
|
+
}
|
|
1901
1678
|
|
|
1679
|
+
// Return invocation when dragEl is inserted (or completed)
|
|
1902
1680
|
function completed(insertion) {
|
|
1903
1681
|
dragOverEvent('dragOverCompleted', {
|
|
1904
1682
|
insertion: insertion
|
|
1905
1683
|
});
|
|
1906
|
-
|
|
1907
1684
|
if (insertion) {
|
|
1908
1685
|
// Clones must be hidden before folding animation to capture dragRectAbsolute properly
|
|
1909
1686
|
if (isOwner) {
|
|
@@ -1911,57 +1688,51 @@
|
|
|
1911
1688
|
} else {
|
|
1912
1689
|
activeSortable._showClone(_this);
|
|
1913
1690
|
}
|
|
1914
|
-
|
|
1915
1691
|
if (_this !== fromSortable) {
|
|
1916
1692
|
// Set ghost class to new sortable's ghost class
|
|
1917
1693
|
toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
|
|
1918
1694
|
toggleClass(dragEl, options.ghostClass, true);
|
|
1919
1695
|
}
|
|
1920
|
-
|
|
1921
1696
|
if (putSortable !== _this && _this !== Sortable.active) {
|
|
1922
1697
|
putSortable = _this;
|
|
1923
1698
|
} else if (_this === Sortable.active && putSortable) {
|
|
1924
1699
|
putSortable = null;
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1700
|
+
}
|
|
1927
1701
|
|
|
1702
|
+
// Animation
|
|
1928
1703
|
if (fromSortable === _this) {
|
|
1929
1704
|
_this._ignoreWhileAnimating = target;
|
|
1930
1705
|
}
|
|
1931
|
-
|
|
1932
1706
|
_this.animateAll(function () {
|
|
1933
1707
|
dragOverEvent('dragOverAnimationComplete');
|
|
1934
1708
|
_this._ignoreWhileAnimating = null;
|
|
1935
1709
|
});
|
|
1936
|
-
|
|
1937
1710
|
if (_this !== fromSortable) {
|
|
1938
1711
|
fromSortable.animateAll();
|
|
1939
1712
|
fromSortable._ignoreWhileAnimating = null;
|
|
1940
1713
|
}
|
|
1941
|
-
}
|
|
1942
|
-
|
|
1714
|
+
}
|
|
1943
1715
|
|
|
1716
|
+
// Null lastTarget if it is not inside a previously swapped element
|
|
1944
1717
|
if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
|
|
1945
1718
|
lastTarget = null;
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1719
|
+
}
|
|
1948
1720
|
|
|
1721
|
+
// no bubbling and not fallback
|
|
1949
1722
|
if (!options.dragoverBubble && !evt.rootEl && target !== document) {
|
|
1950
|
-
dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
|
|
1951
|
-
|
|
1723
|
+
dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
|
|
1952
1724
|
|
|
1725
|
+
// Do not detect for empty insert if already inserted
|
|
1953
1726
|
!insertion && nearestEmptyInsertDetectEvent(evt);
|
|
1954
1727
|
}
|
|
1955
|
-
|
|
1956
1728
|
!options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
|
|
1957
1729
|
return completedFired = true;
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1730
|
+
}
|
|
1960
1731
|
|
|
1732
|
+
// Call when dragEl has been inserted
|
|
1961
1733
|
function changed() {
|
|
1962
1734
|
newIndex = index(dragEl);
|
|
1963
1735
|
newDraggableIndex = index(dragEl, options.draggable);
|
|
1964
|
-
|
|
1965
1736
|
_dispatchEvent({
|
|
1966
1737
|
sortable: _this,
|
|
1967
1738
|
name: 'change',
|
|
@@ -1971,37 +1742,27 @@
|
|
|
1971
1742
|
originalEvent: evt
|
|
1972
1743
|
});
|
|
1973
1744
|
}
|
|
1974
|
-
|
|
1975
1745
|
if (evt.preventDefault !== void 0) {
|
|
1976
1746
|
evt.cancelable && evt.preventDefault();
|
|
1977
1747
|
}
|
|
1978
|
-
|
|
1979
1748
|
target = closest(target, options.draggable, el, true);
|
|
1980
1749
|
dragOverEvent('dragOver');
|
|
1981
1750
|
if (Sortable.eventCanceled) return completedFired;
|
|
1982
|
-
|
|
1983
1751
|
if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
|
|
1984
1752
|
return completed(false);
|
|
1985
1753
|
}
|
|
1986
|
-
|
|
1987
1754
|
ignoreNextClick = false;
|
|
1988
|
-
|
|
1989
1755
|
if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
|
|
1990
1756
|
: putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
|
|
1991
1757
|
vertical = this._getDirection(evt, target) === 'vertical';
|
|
1992
1758
|
dragRect = getRect(dragEl);
|
|
1993
1759
|
dragOverEvent('dragOverValid');
|
|
1994
1760
|
if (Sortable.eventCanceled) return completedFired;
|
|
1995
|
-
|
|
1996
1761
|
if (revert) {
|
|
1997
1762
|
parentEl = rootEl; // actualization
|
|
1998
|
-
|
|
1999
1763
|
capture();
|
|
2000
|
-
|
|
2001
1764
|
this._hideClone();
|
|
2002
|
-
|
|
2003
1765
|
dragOverEvent('revert');
|
|
2004
|
-
|
|
2005
1766
|
if (!Sortable.eventCanceled) {
|
|
2006
1767
|
if (nextEl) {
|
|
2007
1768
|
rootEl.insertBefore(dragEl, nextEl);
|
|
@@ -2009,31 +1770,32 @@
|
|
|
2009
1770
|
rootEl.appendChild(dragEl);
|
|
2010
1771
|
}
|
|
2011
1772
|
}
|
|
2012
|
-
|
|
2013
1773
|
return completed(true);
|
|
2014
1774
|
}
|
|
2015
|
-
|
|
2016
1775
|
var elLastChild = lastChild(el, options.draggable);
|
|
2017
|
-
|
|
2018
1776
|
if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
|
|
2019
1777
|
// Insert to end of list
|
|
1778
|
+
|
|
2020
1779
|
// If already at end of list: Do not insert
|
|
2021
1780
|
if (elLastChild === dragEl) {
|
|
2022
1781
|
return completed(false);
|
|
2023
|
-
}
|
|
2024
|
-
|
|
1782
|
+
}
|
|
2025
1783
|
|
|
1784
|
+
// if there is a last element, it is the target
|
|
2026
1785
|
if (elLastChild && el === evt.target) {
|
|
2027
1786
|
target = elLastChild;
|
|
2028
1787
|
}
|
|
2029
|
-
|
|
2030
1788
|
if (target) {
|
|
2031
1789
|
targetRect = getRect(target);
|
|
2032
1790
|
}
|
|
2033
|
-
|
|
2034
1791
|
if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
|
|
2035
1792
|
capture();
|
|
2036
|
-
|
|
1793
|
+
if (elLastChild && elLastChild.nextSibling) {
|
|
1794
|
+
// the last draggable element is not the last node
|
|
1795
|
+
el.insertBefore(dragEl, elLastChild.nextSibling);
|
|
1796
|
+
} else {
|
|
1797
|
+
el.appendChild(dragEl);
|
|
1798
|
+
}
|
|
2037
1799
|
parentEl = el; // actualization
|
|
2038
1800
|
|
|
2039
1801
|
changed();
|
|
@@ -2042,14 +1804,11 @@
|
|
|
2042
1804
|
} else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
|
|
2043
1805
|
// Insert to start of list
|
|
2044
1806
|
var firstChild = getChild(el, 0, options, true);
|
|
2045
|
-
|
|
2046
1807
|
if (firstChild === dragEl) {
|
|
2047
1808
|
return completed(false);
|
|
2048
1809
|
}
|
|
2049
|
-
|
|
2050
1810
|
target = firstChild;
|
|
2051
1811
|
targetRect = getRect(target);
|
|
2052
|
-
|
|
2053
1812
|
if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
|
|
2054
1813
|
capture();
|
|
2055
1814
|
el.insertBefore(dragEl, firstChild);
|
|
@@ -2061,82 +1820,68 @@
|
|
|
2061
1820
|
} else if (target.parentNode === el) {
|
|
2062
1821
|
targetRect = getRect(target);
|
|
2063
1822
|
var direction = 0,
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
1823
|
+
targetBeforeFirstSwap,
|
|
1824
|
+
differentLevel = dragEl.parentNode !== el,
|
|
1825
|
+
differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
|
|
1826
|
+
side1 = vertical ? 'top' : 'left',
|
|
1827
|
+
scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
|
|
1828
|
+
scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
|
|
2071
1829
|
if (lastTarget !== target) {
|
|
2072
1830
|
targetBeforeFirstSwap = targetRect[side1];
|
|
2073
1831
|
pastFirstInvertThresh = false;
|
|
2074
1832
|
isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
|
|
2075
1833
|
}
|
|
2076
|
-
|
|
2077
1834
|
direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
|
|
2078
1835
|
var sibling;
|
|
2079
|
-
|
|
2080
1836
|
if (direction !== 0) {
|
|
2081
1837
|
// Check if target is beside dragEl in respective direction (ignoring hidden elements)
|
|
2082
1838
|
var dragIndex = index(dragEl);
|
|
2083
|
-
|
|
2084
1839
|
do {
|
|
2085
1840
|
dragIndex -= direction;
|
|
2086
1841
|
sibling = parentEl.children[dragIndex];
|
|
2087
1842
|
} while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
|
|
1843
|
+
}
|
|
1844
|
+
// If dragEl is already beside target: Do not insert
|
|
2091
1845
|
if (direction === 0 || sibling === target) {
|
|
2092
1846
|
return completed(false);
|
|
2093
1847
|
}
|
|
2094
|
-
|
|
2095
1848
|
lastTarget = target;
|
|
2096
1849
|
lastDirection = direction;
|
|
2097
1850
|
var nextSibling = target.nextElementSibling,
|
|
2098
|
-
|
|
1851
|
+
after = false;
|
|
2099
1852
|
after = direction === 1;
|
|
2100
|
-
|
|
2101
1853
|
var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
|
|
2102
|
-
|
|
2103
1854
|
if (moveVector !== false) {
|
|
2104
1855
|
if (moveVector === 1 || moveVector === -1) {
|
|
2105
1856
|
after = moveVector === 1;
|
|
2106
1857
|
}
|
|
2107
|
-
|
|
2108
1858
|
_silent = true;
|
|
2109
1859
|
setTimeout(_unsilent, 30);
|
|
2110
1860
|
capture();
|
|
2111
|
-
|
|
2112
1861
|
if (after && !nextSibling) {
|
|
2113
1862
|
el.appendChild(dragEl);
|
|
2114
1863
|
} else {
|
|
2115
1864
|
target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
|
|
2116
|
-
}
|
|
2117
|
-
|
|
1865
|
+
}
|
|
2118
1866
|
|
|
1867
|
+
// Undo chrome's scroll adjustment (has no effect on other browsers)
|
|
2119
1868
|
if (scrolledPastTop) {
|
|
2120
1869
|
scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
|
|
2121
1870
|
}
|
|
2122
|
-
|
|
2123
1871
|
parentEl = dragEl.parentNode; // actualization
|
|
2124
|
-
// must be done before animation
|
|
2125
1872
|
|
|
1873
|
+
// must be done before animation
|
|
2126
1874
|
if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
|
|
2127
1875
|
targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
|
|
2128
1876
|
}
|
|
2129
|
-
|
|
2130
1877
|
changed();
|
|
2131
1878
|
return completed(true);
|
|
2132
1879
|
}
|
|
2133
1880
|
}
|
|
2134
|
-
|
|
2135
1881
|
if (el.contains(dragEl)) {
|
|
2136
1882
|
return completed(false);
|
|
2137
1883
|
}
|
|
2138
1884
|
}
|
|
2139
|
-
|
|
2140
1885
|
return false;
|
|
2141
1886
|
},
|
|
2142
1887
|
_ignoreWhileAnimating: null,
|
|
@@ -2156,83 +1901,69 @@
|
|
|
2156
1901
|
off(ownerDocument, 'touchcancel', this._onDrop);
|
|
2157
1902
|
off(document, 'selectstart', this);
|
|
2158
1903
|
},
|
|
2159
|
-
_onDrop: function _onDrop(
|
|
2160
|
-
/**Event*/
|
|
2161
|
-
evt) {
|
|
1904
|
+
_onDrop: function _onDrop( /**Event*/evt) {
|
|
2162
1905
|
var el = this.el,
|
|
2163
|
-
|
|
1906
|
+
options = this.options;
|
|
2164
1907
|
|
|
1908
|
+
// Get the index of the dragged element within its parent
|
|
2165
1909
|
newIndex = index(dragEl);
|
|
2166
1910
|
newDraggableIndex = index(dragEl, options.draggable);
|
|
2167
1911
|
pluginEvent('drop', this, {
|
|
2168
1912
|
evt: evt
|
|
2169
1913
|
});
|
|
2170
|
-
parentEl = dragEl && dragEl.parentNode;
|
|
1914
|
+
parentEl = dragEl && dragEl.parentNode;
|
|
2171
1915
|
|
|
1916
|
+
// Get again after plugin event
|
|
2172
1917
|
newIndex = index(dragEl);
|
|
2173
1918
|
newDraggableIndex = index(dragEl, options.draggable);
|
|
2174
|
-
|
|
2175
1919
|
if (Sortable.eventCanceled) {
|
|
2176
1920
|
this._nulling();
|
|
2177
|
-
|
|
2178
1921
|
return;
|
|
2179
1922
|
}
|
|
2180
|
-
|
|
2181
1923
|
awaitingDragStarted = false;
|
|
2182
1924
|
isCircumstantialInvert = false;
|
|
2183
1925
|
pastFirstInvertThresh = false;
|
|
2184
1926
|
clearInterval(this._loopId);
|
|
2185
1927
|
clearTimeout(this._dragStartTimer);
|
|
2186
|
-
|
|
2187
1928
|
_cancelNextTick(this.cloneId);
|
|
1929
|
+
_cancelNextTick(this._dragStartId);
|
|
2188
1930
|
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
1931
|
+
// Unbind events
|
|
2192
1932
|
if (this.nativeDraggable) {
|
|
2193
1933
|
off(document, 'drop', this);
|
|
2194
1934
|
off(el, 'dragstart', this._onDragStart);
|
|
2195
1935
|
}
|
|
2196
|
-
|
|
2197
1936
|
this._offMoveEvents();
|
|
2198
|
-
|
|
2199
1937
|
this._offUpEvents();
|
|
2200
|
-
|
|
2201
1938
|
if (Safari) {
|
|
2202
1939
|
css(document.body, 'user-select', '');
|
|
2203
1940
|
}
|
|
2204
|
-
|
|
2205
1941
|
css(dragEl, 'transform', '');
|
|
2206
|
-
|
|
2207
1942
|
if (evt) {
|
|
2208
1943
|
if (moved) {
|
|
2209
1944
|
evt.cancelable && evt.preventDefault();
|
|
2210
1945
|
!options.dropBubble && evt.stopPropagation();
|
|
2211
1946
|
}
|
|
2212
|
-
|
|
2213
1947
|
ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
|
|
2214
|
-
|
|
2215
1948
|
if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
|
|
2216
1949
|
// Remove clone(s)
|
|
2217
1950
|
cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
|
|
2218
1951
|
}
|
|
2219
|
-
|
|
2220
1952
|
if (dragEl) {
|
|
2221
1953
|
if (this.nativeDraggable) {
|
|
2222
1954
|
off(dragEl, 'dragend', this);
|
|
2223
1955
|
}
|
|
2224
|
-
|
|
2225
1956
|
_disableDraggable(dragEl);
|
|
1957
|
+
dragEl.style['will-change'] = '';
|
|
2226
1958
|
|
|
2227
|
-
|
|
1959
|
+
// Remove classes
|
|
2228
1960
|
// ghostClass is added in dragStarted
|
|
2229
|
-
|
|
2230
1961
|
if (moved && !awaitingDragStarted) {
|
|
2231
1962
|
toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
|
|
2232
1963
|
}
|
|
1964
|
+
toggleClass(dragEl, this.options.chosenClass, false);
|
|
2233
1965
|
|
|
2234
|
-
|
|
2235
|
-
|
|
1966
|
+
// Drag stop event
|
|
2236
1967
|
_dispatchEvent({
|
|
2237
1968
|
sortable: this,
|
|
2238
1969
|
name: 'unchoose',
|
|
@@ -2241,7 +1972,6 @@
|
|
|
2241
1972
|
newDraggableIndex: null,
|
|
2242
1973
|
originalEvent: evt
|
|
2243
1974
|
});
|
|
2244
|
-
|
|
2245
1975
|
if (rootEl !== parentEl) {
|
|
2246
1976
|
if (newIndex >= 0) {
|
|
2247
1977
|
// Add event
|
|
@@ -2251,17 +1981,17 @@
|
|
|
2251
1981
|
toEl: parentEl,
|
|
2252
1982
|
fromEl: rootEl,
|
|
2253
1983
|
originalEvent: evt
|
|
2254
|
-
});
|
|
2255
|
-
|
|
1984
|
+
});
|
|
2256
1985
|
|
|
1986
|
+
// Remove event
|
|
2257
1987
|
_dispatchEvent({
|
|
2258
1988
|
sortable: this,
|
|
2259
1989
|
name: 'remove',
|
|
2260
1990
|
toEl: parentEl,
|
|
2261
1991
|
originalEvent: evt
|
|
2262
|
-
});
|
|
2263
|
-
|
|
1992
|
+
});
|
|
2264
1993
|
|
|
1994
|
+
// drag from one list and drop into another
|
|
2265
1995
|
_dispatchEvent({
|
|
2266
1996
|
rootEl: parentEl,
|
|
2267
1997
|
name: 'sort',
|
|
@@ -2269,7 +1999,6 @@
|
|
|
2269
1999
|
fromEl: rootEl,
|
|
2270
2000
|
originalEvent: evt
|
|
2271
2001
|
});
|
|
2272
|
-
|
|
2273
2002
|
_dispatchEvent({
|
|
2274
2003
|
sortable: this,
|
|
2275
2004
|
name: 'sort',
|
|
@@ -2277,7 +2006,6 @@
|
|
|
2277
2006
|
originalEvent: evt
|
|
2278
2007
|
});
|
|
2279
2008
|
}
|
|
2280
|
-
|
|
2281
2009
|
putSortable && putSortable.save();
|
|
2282
2010
|
} else {
|
|
2283
2011
|
if (newIndex !== oldIndex) {
|
|
@@ -2289,7 +2017,6 @@
|
|
|
2289
2017
|
toEl: parentEl,
|
|
2290
2018
|
originalEvent: evt
|
|
2291
2019
|
});
|
|
2292
|
-
|
|
2293
2020
|
_dispatchEvent({
|
|
2294
2021
|
sortable: this,
|
|
2295
2022
|
name: 'sort',
|
|
@@ -2299,27 +2026,24 @@
|
|
|
2299
2026
|
}
|
|
2300
2027
|
}
|
|
2301
2028
|
}
|
|
2302
|
-
|
|
2303
2029
|
if (Sortable.active) {
|
|
2304
2030
|
/* jshint eqnull:true */
|
|
2305
2031
|
if (newIndex == null || newIndex === -1) {
|
|
2306
2032
|
newIndex = oldIndex;
|
|
2307
2033
|
newDraggableIndex = oldDraggableIndex;
|
|
2308
2034
|
}
|
|
2309
|
-
|
|
2310
2035
|
_dispatchEvent({
|
|
2311
2036
|
sortable: this,
|
|
2312
2037
|
name: 'end',
|
|
2313
2038
|
toEl: parentEl,
|
|
2314
2039
|
originalEvent: evt
|
|
2315
|
-
});
|
|
2316
|
-
|
|
2040
|
+
});
|
|
2317
2041
|
|
|
2042
|
+
// Save sorting
|
|
2318
2043
|
this.save();
|
|
2319
2044
|
}
|
|
2320
2045
|
}
|
|
2321
2046
|
}
|
|
2322
|
-
|
|
2323
2047
|
this._nulling();
|
|
2324
2048
|
},
|
|
2325
2049
|
_nulling: function _nulling() {
|
|
@@ -2330,65 +2054,52 @@
|
|
|
2330
2054
|
});
|
|
2331
2055
|
savedInputChecked.length = lastDx = lastDy = 0;
|
|
2332
2056
|
},
|
|
2333
|
-
handleEvent: function handleEvent(
|
|
2334
|
-
/**Event*/
|
|
2335
|
-
evt) {
|
|
2057
|
+
handleEvent: function handleEvent( /**Event*/evt) {
|
|
2336
2058
|
switch (evt.type) {
|
|
2337
2059
|
case 'drop':
|
|
2338
2060
|
case 'dragend':
|
|
2339
2061
|
this._onDrop(evt);
|
|
2340
|
-
|
|
2341
2062
|
break;
|
|
2342
|
-
|
|
2343
2063
|
case 'dragenter':
|
|
2344
2064
|
case 'dragover':
|
|
2345
2065
|
if (dragEl) {
|
|
2346
2066
|
this._onDragOver(evt);
|
|
2347
|
-
|
|
2348
2067
|
_globalDragOver(evt);
|
|
2349
2068
|
}
|
|
2350
|
-
|
|
2351
2069
|
break;
|
|
2352
|
-
|
|
2353
2070
|
case 'selectstart':
|
|
2354
2071
|
evt.preventDefault();
|
|
2355
2072
|
break;
|
|
2356
2073
|
}
|
|
2357
2074
|
},
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
*
|
|
2361
|
-
* @returns {String[]}
|
|
2075
|
+
/**
|
|
2076
|
+
* Serializes the item into an array of string.
|
|
2077
|
+
* @returns {String[]}
|
|
2362
2078
|
*/
|
|
2363
2079
|
toArray: function toArray() {
|
|
2364
2080
|
var order = [],
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2081
|
+
el,
|
|
2082
|
+
children = this.el.children,
|
|
2083
|
+
i = 0,
|
|
2084
|
+
n = children.length,
|
|
2085
|
+
options = this.options;
|
|
2371
2086
|
for (; i < n; i++) {
|
|
2372
2087
|
el = children[i];
|
|
2373
|
-
|
|
2374
2088
|
if (closest(el, options.draggable, this.el, false)) {
|
|
2375
2089
|
order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
|
|
2376
2090
|
}
|
|
2377
2091
|
}
|
|
2378
|
-
|
|
2379
2092
|
return order;
|
|
2380
2093
|
},
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
*
|
|
2384
|
-
* @param {String[]} order order of the items
|
|
2094
|
+
/**
|
|
2095
|
+
* Sorts the elements according to the array.
|
|
2096
|
+
* @param {String[]} order order of the items
|
|
2385
2097
|
*/
|
|
2386
2098
|
sort: function sort(order, useAnimation) {
|
|
2387
2099
|
var items = {},
|
|
2388
|
-
|
|
2100
|
+
rootEl = this.el;
|
|
2389
2101
|
this.toArray().forEach(function (id, i) {
|
|
2390
2102
|
var el = rootEl.children[i];
|
|
2391
|
-
|
|
2392
2103
|
if (closest(el, this.options.draggable, rootEl, false)) {
|
|
2393
2104
|
items[id] = el;
|
|
2394
2105
|
}
|
|
@@ -2402,53 +2113,46 @@
|
|
|
2402
2113
|
});
|
|
2403
2114
|
useAnimation && this.animateAll();
|
|
2404
2115
|
},
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
* Save the current sorting
|
|
2116
|
+
/**
|
|
2117
|
+
* Save the current sorting
|
|
2408
2118
|
*/
|
|
2409
2119
|
save: function save() {
|
|
2410
2120
|
var store = this.options.store;
|
|
2411
2121
|
store && store.set && store.set(this);
|
|
2412
2122
|
},
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
*
|
|
2416
|
-
* @param {
|
|
2417
|
-
* @
|
|
2418
|
-
* @returns {HTMLElement|null}
|
|
2123
|
+
/**
|
|
2124
|
+
* 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.
|
|
2125
|
+
* @param {HTMLElement} el
|
|
2126
|
+
* @param {String} [selector] default: `options.draggable`
|
|
2127
|
+
* @returns {HTMLElement|null}
|
|
2419
2128
|
*/
|
|
2420
2129
|
closest: function closest$1(el, selector) {
|
|
2421
2130
|
return closest(el, selector || this.options.draggable, this.el, false);
|
|
2422
2131
|
},
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
*
|
|
2426
|
-
* @param {
|
|
2427
|
-
* @
|
|
2428
|
-
* @returns {*}
|
|
2132
|
+
/**
|
|
2133
|
+
* Set/get option
|
|
2134
|
+
* @param {string} name
|
|
2135
|
+
* @param {*} [value]
|
|
2136
|
+
* @returns {*}
|
|
2429
2137
|
*/
|
|
2430
2138
|
option: function option(name, value) {
|
|
2431
2139
|
var options = this.options;
|
|
2432
|
-
|
|
2433
2140
|
if (value === void 0) {
|
|
2434
2141
|
return options[name];
|
|
2435
2142
|
} else {
|
|
2436
2143
|
var modifiedValue = PluginManager.modifyOption(this, name, value);
|
|
2437
|
-
|
|
2438
2144
|
if (typeof modifiedValue !== 'undefined') {
|
|
2439
2145
|
options[name] = modifiedValue;
|
|
2440
2146
|
} else {
|
|
2441
2147
|
options[name] = value;
|
|
2442
2148
|
}
|
|
2443
|
-
|
|
2444
2149
|
if (name === 'group') {
|
|
2445
2150
|
_prepareGroup(options);
|
|
2446
2151
|
}
|
|
2447
2152
|
}
|
|
2448
2153
|
},
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
* Destroy
|
|
2154
|
+
/**
|
|
2155
|
+
* Destroy
|
|
2452
2156
|
*/
|
|
2453
2157
|
destroy: function destroy() {
|
|
2454
2158
|
pluginEvent('destroy', this);
|
|
@@ -2457,21 +2161,16 @@
|
|
|
2457
2161
|
off(el, 'mousedown', this._onTapStart);
|
|
2458
2162
|
off(el, 'touchstart', this._onTapStart);
|
|
2459
2163
|
off(el, 'pointerdown', this._onTapStart);
|
|
2460
|
-
|
|
2461
2164
|
if (this.nativeDraggable) {
|
|
2462
2165
|
off(el, 'dragover', this);
|
|
2463
2166
|
off(el, 'dragenter', this);
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
|
-
|
|
2167
|
+
}
|
|
2168
|
+
// Remove draggable attributes
|
|
2467
2169
|
Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
|
|
2468
2170
|
el.removeAttribute('draggable');
|
|
2469
2171
|
});
|
|
2470
|
-
|
|
2471
2172
|
this._onDrop();
|
|
2472
|
-
|
|
2473
2173
|
this._disableDelayedDragEvents();
|
|
2474
|
-
|
|
2475
2174
|
sortables.splice(sortables.indexOf(this.el), 1);
|
|
2476
2175
|
this.el = el = null;
|
|
2477
2176
|
},
|
|
@@ -2480,25 +2179,22 @@
|
|
|
2480
2179
|
pluginEvent('hideClone', this);
|
|
2481
2180
|
if (Sortable.eventCanceled) return;
|
|
2482
2181
|
css(cloneEl, 'display', 'none');
|
|
2483
|
-
|
|
2484
2182
|
if (this.options.removeCloneOnHide && cloneEl.parentNode) {
|
|
2485
2183
|
cloneEl.parentNode.removeChild(cloneEl);
|
|
2486
2184
|
}
|
|
2487
|
-
|
|
2488
2185
|
cloneHidden = true;
|
|
2489
2186
|
}
|
|
2490
2187
|
},
|
|
2491
2188
|
_showClone: function _showClone(putSortable) {
|
|
2492
2189
|
if (putSortable.lastPutMode !== 'clone') {
|
|
2493
2190
|
this._hideClone();
|
|
2494
|
-
|
|
2495
2191
|
return;
|
|
2496
2192
|
}
|
|
2497
|
-
|
|
2498
2193
|
if (cloneHidden) {
|
|
2499
2194
|
pluginEvent('showClone', this);
|
|
2500
|
-
if (Sortable.eventCanceled) return;
|
|
2195
|
+
if (Sortable.eventCanceled) return;
|
|
2501
2196
|
|
|
2197
|
+
// show clone at dragEl or original position
|
|
2502
2198
|
if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
|
|
2503
2199
|
rootEl.insertBefore(cloneEl, dragEl);
|
|
2504
2200
|
} else if (nextEl) {
|
|
@@ -2506,33 +2202,26 @@
|
|
|
2506
2202
|
} else {
|
|
2507
2203
|
rootEl.appendChild(cloneEl);
|
|
2508
2204
|
}
|
|
2509
|
-
|
|
2510
2205
|
if (this.options.group.revertClone) {
|
|
2511
2206
|
this.animate(dragEl, cloneEl);
|
|
2512
2207
|
}
|
|
2513
|
-
|
|
2514
2208
|
css(cloneEl, 'display', '');
|
|
2515
2209
|
cloneHidden = false;
|
|
2516
2210
|
}
|
|
2517
2211
|
}
|
|
2518
2212
|
};
|
|
2519
|
-
|
|
2520
|
-
function _globalDragOver(
|
|
2521
|
-
/**Event*/
|
|
2522
|
-
evt) {
|
|
2213
|
+
function _globalDragOver( /**Event*/evt) {
|
|
2523
2214
|
if (evt.dataTransfer) {
|
|
2524
2215
|
evt.dataTransfer.dropEffect = 'move';
|
|
2525
2216
|
}
|
|
2526
|
-
|
|
2527
2217
|
evt.cancelable && evt.preventDefault();
|
|
2528
2218
|
}
|
|
2529
|
-
|
|
2530
2219
|
function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
|
|
2531
2220
|
var evt,
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2221
|
+
sortable = fromEl[expando],
|
|
2222
|
+
onMoveFn = sortable.options.onMove,
|
|
2223
|
+
retVal;
|
|
2224
|
+
// Support for new CustomEvent feature
|
|
2536
2225
|
if (window.CustomEvent && !IE11OrLess && !Edge) {
|
|
2537
2226
|
evt = new CustomEvent('move', {
|
|
2538
2227
|
bubbles: true,
|
|
@@ -2542,7 +2231,6 @@
|
|
|
2542
2231
|
evt = document.createEvent('Event');
|
|
2543
2232
|
evt.initEvent('move', true, true);
|
|
2544
2233
|
}
|
|
2545
|
-
|
|
2546
2234
|
evt.to = toEl;
|
|
2547
2235
|
evt.from = fromEl;
|
|
2548
2236
|
evt.dragged = dragEl;
|
|
@@ -2552,41 +2240,35 @@
|
|
|
2552
2240
|
evt.willInsertAfter = willInsertAfter;
|
|
2553
2241
|
evt.originalEvent = originalEvent;
|
|
2554
2242
|
fromEl.dispatchEvent(evt);
|
|
2555
|
-
|
|
2556
2243
|
if (onMoveFn) {
|
|
2557
2244
|
retVal = onMoveFn.call(sortable, evt, originalEvent);
|
|
2558
2245
|
}
|
|
2559
|
-
|
|
2560
2246
|
return retVal;
|
|
2561
2247
|
}
|
|
2562
|
-
|
|
2563
2248
|
function _disableDraggable(el) {
|
|
2564
2249
|
el.draggable = false;
|
|
2565
2250
|
}
|
|
2566
|
-
|
|
2567
2251
|
function _unsilent() {
|
|
2568
2252
|
_silent = false;
|
|
2569
2253
|
}
|
|
2570
|
-
|
|
2571
2254
|
function _ghostIsFirst(evt, vertical, sortable) {
|
|
2572
|
-
var
|
|
2255
|
+
var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
|
|
2256
|
+
var sortableContentRect = getContentRect(sortable.el);
|
|
2573
2257
|
var spacer = 10;
|
|
2574
|
-
return vertical ? evt.clientX <
|
|
2258
|
+
return vertical ? evt.clientX < sortableContentRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < sortableContentRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
|
|
2575
2259
|
}
|
|
2576
|
-
|
|
2577
2260
|
function _ghostIsLast(evt, vertical, sortable) {
|
|
2578
|
-
var
|
|
2261
|
+
var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
|
|
2262
|
+
var sortableContentRect = getContentRect(sortable.el);
|
|
2579
2263
|
var spacer = 10;
|
|
2580
|
-
return vertical ? evt.clientX >
|
|
2264
|
+
return vertical ? evt.clientX > sortableContentRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > sortableContentRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
|
|
2581
2265
|
}
|
|
2582
|
-
|
|
2583
2266
|
function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
|
|
2584
2267
|
var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2268
|
+
targetLength = vertical ? targetRect.height : targetRect.width,
|
|
2269
|
+
targetS1 = vertical ? targetRect.top : targetRect.left,
|
|
2270
|
+
targetS2 = vertical ? targetRect.bottom : targetRect.right,
|
|
2271
|
+
invert = false;
|
|
2590
2272
|
if (!invertSwap) {
|
|
2591
2273
|
// Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
|
|
2592
2274
|
if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
|
|
@@ -2596,7 +2278,6 @@
|
|
|
2596
2278
|
// past first invert threshold, do not restrict inverted threshold to dragEl shadow
|
|
2597
2279
|
pastFirstInvertThresh = true;
|
|
2598
2280
|
}
|
|
2599
|
-
|
|
2600
2281
|
if (!pastFirstInvertThresh) {
|
|
2601
2282
|
// dragEl shadow (target move distance shadow)
|
|
2602
2283
|
if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
|
|
@@ -2613,26 +2294,22 @@
|
|
|
2613
2294
|
}
|
|
2614
2295
|
}
|
|
2615
2296
|
}
|
|
2616
|
-
|
|
2617
2297
|
invert = invert || invertSwap;
|
|
2618
|
-
|
|
2619
2298
|
if (invert) {
|
|
2620
2299
|
// Invert of regular
|
|
2621
2300
|
if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
|
|
2622
2301
|
return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
|
|
2623
2302
|
}
|
|
2624
2303
|
}
|
|
2625
|
-
|
|
2626
2304
|
return 0;
|
|
2627
2305
|
}
|
|
2628
|
-
/**
|
|
2629
|
-
* Gets the direction dragEl must be swapped relative to target in order to make it
|
|
2630
|
-
* seem that dragEl has been "inserted" into that element's position
|
|
2631
|
-
* @param {HTMLElement} target The target whose position dragEl is being inserted at
|
|
2632
|
-
* @return {Number} Direction dragEl must be swapped
|
|
2633
|
-
*/
|
|
2634
|
-
|
|
2635
2306
|
|
|
2307
|
+
/**
|
|
2308
|
+
* Gets the direction dragEl must be swapped relative to target in order to make it
|
|
2309
|
+
* seem that dragEl has been "inserted" into that element's position
|
|
2310
|
+
* @param {HTMLElement} target The target whose position dragEl is being inserted at
|
|
2311
|
+
* @return {Number} Direction dragEl must be swapped
|
|
2312
|
+
*/
|
|
2636
2313
|
function _getInsertDirection(target) {
|
|
2637
2314
|
if (index(dragEl) < index(target)) {
|
|
2638
2315
|
return 1;
|
|
@@ -2640,55 +2317,48 @@
|
|
|
2640
2317
|
return -1;
|
|
2641
2318
|
}
|
|
2642
2319
|
}
|
|
2643
|
-
/**
|
|
2644
|
-
* Generate id
|
|
2645
|
-
* @param {HTMLElement} el
|
|
2646
|
-
* @returns {String}
|
|
2647
|
-
* @private
|
|
2648
|
-
*/
|
|
2649
|
-
|
|
2650
2320
|
|
|
2321
|
+
/**
|
|
2322
|
+
* Generate id
|
|
2323
|
+
* @param {HTMLElement} el
|
|
2324
|
+
* @returns {String}
|
|
2325
|
+
* @private
|
|
2326
|
+
*/
|
|
2651
2327
|
function _generateId(el) {
|
|
2652
2328
|
var str = el.tagName + el.className + el.src + el.href + el.textContent,
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2329
|
+
i = str.length,
|
|
2330
|
+
sum = 0;
|
|
2656
2331
|
while (i--) {
|
|
2657
2332
|
sum += str.charCodeAt(i);
|
|
2658
2333
|
}
|
|
2659
|
-
|
|
2660
2334
|
return sum.toString(36);
|
|
2661
2335
|
}
|
|
2662
|
-
|
|
2663
2336
|
function _saveInputCheckedState(root) {
|
|
2664
2337
|
savedInputChecked.length = 0;
|
|
2665
2338
|
var inputs = root.getElementsByTagName('input');
|
|
2666
2339
|
var idx = inputs.length;
|
|
2667
|
-
|
|
2668
2340
|
while (idx--) {
|
|
2669
2341
|
var el = inputs[idx];
|
|
2670
2342
|
el.checked && savedInputChecked.push(el);
|
|
2671
2343
|
}
|
|
2672
2344
|
}
|
|
2673
|
-
|
|
2674
2345
|
function _nextTick(fn) {
|
|
2675
2346
|
return setTimeout(fn, 0);
|
|
2676
2347
|
}
|
|
2677
|
-
|
|
2678
2348
|
function _cancelNextTick(id) {
|
|
2679
2349
|
return clearTimeout(id);
|
|
2680
|
-
}
|
|
2681
|
-
|
|
2350
|
+
}
|
|
2682
2351
|
|
|
2352
|
+
// Fixed #973:
|
|
2683
2353
|
if (documentExists) {
|
|
2684
2354
|
on(document, 'touchmove', function (evt) {
|
|
2685
2355
|
if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
|
|
2686
2356
|
evt.preventDefault();
|
|
2687
2357
|
}
|
|
2688
2358
|
});
|
|
2689
|
-
}
|
|
2690
|
-
|
|
2359
|
+
}
|
|
2691
2360
|
|
|
2361
|
+
// Export utils
|
|
2692
2362
|
Sortable.utils = {
|
|
2693
2363
|
on: on,
|
|
2694
2364
|
off: off,
|
|
@@ -2708,59 +2378,54 @@
|
|
|
2708
2378
|
detectDirection: _detectDirection,
|
|
2709
2379
|
getChild: getChild
|
|
2710
2380
|
};
|
|
2711
|
-
/**
|
|
2712
|
-
* Get the Sortable instance of an element
|
|
2713
|
-
* @param {HTMLElement} element The element
|
|
2714
|
-
* @return {Sortable|undefined} The instance of Sortable
|
|
2715
|
-
*/
|
|
2716
2381
|
|
|
2382
|
+
/**
|
|
2383
|
+
* Get the Sortable instance of an element
|
|
2384
|
+
* @param {HTMLElement} element The element
|
|
2385
|
+
* @return {Sortable|undefined} The instance of Sortable
|
|
2386
|
+
*/
|
|
2717
2387
|
Sortable.get = function (element) {
|
|
2718
2388
|
return element[expando];
|
|
2719
2389
|
};
|
|
2720
|
-
/**
|
|
2721
|
-
* Mount a plugin to Sortable
|
|
2722
|
-
* @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
|
|
2723
|
-
*/
|
|
2724
|
-
|
|
2725
2390
|
|
|
2391
|
+
/**
|
|
2392
|
+
* Mount a plugin to Sortable
|
|
2393
|
+
* @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
|
|
2394
|
+
*/
|
|
2726
2395
|
Sortable.mount = function () {
|
|
2727
2396
|
for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2728
2397
|
plugins[_key] = arguments[_key];
|
|
2729
2398
|
}
|
|
2730
|
-
|
|
2731
2399
|
if (plugins[0].constructor === Array) plugins = plugins[0];
|
|
2732
2400
|
plugins.forEach(function (plugin) {
|
|
2733
2401
|
if (!plugin.prototype || !plugin.prototype.constructor) {
|
|
2734
2402
|
throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
|
|
2735
2403
|
}
|
|
2736
|
-
|
|
2737
2404
|
if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
|
|
2738
2405
|
PluginManager.mount(plugin);
|
|
2739
2406
|
});
|
|
2740
2407
|
};
|
|
2741
|
-
/**
|
|
2742
|
-
* Create sortable instance
|
|
2743
|
-
* @param {HTMLElement} el
|
|
2744
|
-
* @param {Object} [options]
|
|
2745
|
-
*/
|
|
2746
|
-
|
|
2747
2408
|
|
|
2409
|
+
/**
|
|
2410
|
+
* Create sortable instance
|
|
2411
|
+
* @param {HTMLElement} el
|
|
2412
|
+
* @param {Object} [options]
|
|
2413
|
+
*/
|
|
2748
2414
|
Sortable.create = function (el, options) {
|
|
2749
2415
|
return new Sortable(el, options);
|
|
2750
|
-
};
|
|
2751
|
-
|
|
2416
|
+
};
|
|
2752
2417
|
|
|
2418
|
+
// Export
|
|
2753
2419
|
Sortable.version = version;
|
|
2754
2420
|
|
|
2755
2421
|
var autoScrolls = [],
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2422
|
+
scrollEl,
|
|
2423
|
+
scrollRootEl,
|
|
2424
|
+
scrolling = false,
|
|
2425
|
+
lastAutoScrollX,
|
|
2426
|
+
lastAutoScrollY,
|
|
2427
|
+
touchEvt$1,
|
|
2428
|
+
pointerElemChangedInterval;
|
|
2764
2429
|
function AutoScrollPlugin() {
|
|
2765
2430
|
function AutoScroll() {
|
|
2766
2431
|
this.defaults = {
|
|
@@ -2769,19 +2434,18 @@
|
|
|
2769
2434
|
scrollSensitivity: 30,
|
|
2770
2435
|
scrollSpeed: 10,
|
|
2771
2436
|
bubbleScroll: true
|
|
2772
|
-
};
|
|
2437
|
+
};
|
|
2773
2438
|
|
|
2439
|
+
// Bind all private methods
|
|
2774
2440
|
for (var fn in this) {
|
|
2775
2441
|
if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
|
|
2776
2442
|
this[fn] = this[fn].bind(this);
|
|
2777
2443
|
}
|
|
2778
2444
|
}
|
|
2779
2445
|
}
|
|
2780
|
-
|
|
2781
2446
|
AutoScroll.prototype = {
|
|
2782
2447
|
dragStarted: function dragStarted(_ref) {
|
|
2783
2448
|
var originalEvent = _ref.originalEvent;
|
|
2784
|
-
|
|
2785
2449
|
if (this.sortable.nativeDraggable) {
|
|
2786
2450
|
on(document, 'dragover', this._handleAutoScroll);
|
|
2787
2451
|
} else {
|
|
@@ -2796,7 +2460,6 @@
|
|
|
2796
2460
|
},
|
|
2797
2461
|
dragOverCompleted: function dragOverCompleted(_ref2) {
|
|
2798
2462
|
var originalEvent = _ref2.originalEvent;
|
|
2799
|
-
|
|
2800
2463
|
// For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
|
|
2801
2464
|
if (!this.options.dragOverBubble && !originalEvent.rootEl) {
|
|
2802
2465
|
this._handleAutoScroll(originalEvent);
|
|
@@ -2810,7 +2473,6 @@
|
|
|
2810
2473
|
off(document, 'touchmove', this._handleFallbackAutoScroll);
|
|
2811
2474
|
off(document, 'mousemove', this._handleFallbackAutoScroll);
|
|
2812
2475
|
}
|
|
2813
|
-
|
|
2814
2476
|
clearPointerElemChangedInterval();
|
|
2815
2477
|
clearAutoScrolls();
|
|
2816
2478
|
cancelThrottle();
|
|
@@ -2824,31 +2486,29 @@
|
|
|
2824
2486
|
},
|
|
2825
2487
|
_handleAutoScroll: function _handleAutoScroll(evt, fallback) {
|
|
2826
2488
|
var _this = this;
|
|
2827
|
-
|
|
2828
2489
|
var x = (evt.touches ? evt.touches[0] : evt).clientX,
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
touchEvt$1 = evt;
|
|
2490
|
+
y = (evt.touches ? evt.touches[0] : evt).clientY,
|
|
2491
|
+
elem = document.elementFromPoint(x, y);
|
|
2492
|
+
touchEvt$1 = evt;
|
|
2493
|
+
|
|
2494
|
+
// IE does not seem to have native autoscroll,
|
|
2832
2495
|
// Edge's autoscroll seems too conditional,
|
|
2833
2496
|
// MACOS Safari does not have autoscroll,
|
|
2834
2497
|
// Firefox and Chrome are good
|
|
2835
|
-
|
|
2836
2498
|
if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
|
|
2837
|
-
autoScroll(evt, this.options, elem, fallback);
|
|
2499
|
+
autoScroll(evt, this.options, elem, fallback);
|
|
2838
2500
|
|
|
2501
|
+
// Listener for pointer element change
|
|
2839
2502
|
var ogElemScroller = getParentAutoScrollElement(elem, true);
|
|
2840
|
-
|
|
2841
2503
|
if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
|
|
2842
|
-
pointerElemChangedInterval && clearPointerElemChangedInterval();
|
|
2843
|
-
|
|
2504
|
+
pointerElemChangedInterval && clearPointerElemChangedInterval();
|
|
2505
|
+
// Detect for pointer elem change, emulating native DnD behaviour
|
|
2844
2506
|
pointerElemChangedInterval = setInterval(function () {
|
|
2845
2507
|
var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
|
|
2846
|
-
|
|
2847
2508
|
if (newElem !== ogElemScroller) {
|
|
2848
2509
|
ogElemScroller = newElem;
|
|
2849
2510
|
clearAutoScrolls();
|
|
2850
2511
|
}
|
|
2851
|
-
|
|
2852
2512
|
autoScroll(evt, _this.options, newElem, fallback);
|
|
2853
2513
|
}, 10);
|
|
2854
2514
|
lastAutoScrollX = x;
|
|
@@ -2860,7 +2520,6 @@
|
|
|
2860
2520
|
clearAutoScrolls();
|
|
2861
2521
|
return;
|
|
2862
2522
|
}
|
|
2863
|
-
|
|
2864
2523
|
autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
|
|
2865
2524
|
}
|
|
2866
2525
|
}
|
|
@@ -2870,60 +2529,54 @@
|
|
|
2870
2529
|
initializeByDefault: true
|
|
2871
2530
|
});
|
|
2872
2531
|
}
|
|
2873
|
-
|
|
2874
2532
|
function clearAutoScrolls() {
|
|
2875
2533
|
autoScrolls.forEach(function (autoScroll) {
|
|
2876
2534
|
clearInterval(autoScroll.pid);
|
|
2877
2535
|
});
|
|
2878
2536
|
autoScrolls = [];
|
|
2879
2537
|
}
|
|
2880
|
-
|
|
2881
2538
|
function clearPointerElemChangedInterval() {
|
|
2882
2539
|
clearInterval(pointerElemChangedInterval);
|
|
2883
2540
|
}
|
|
2884
|
-
|
|
2885
2541
|
var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
|
|
2886
2542
|
// Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
|
|
2887
2543
|
if (!options.scroll) return;
|
|
2888
2544
|
var x = (evt.touches ? evt.touches[0] : evt).clientX,
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2545
|
+
y = (evt.touches ? evt.touches[0] : evt).clientY,
|
|
2546
|
+
sens = options.scrollSensitivity,
|
|
2547
|
+
speed = options.scrollSpeed,
|
|
2548
|
+
winScroller = getWindowScrollingElement();
|
|
2893
2549
|
var scrollThisInstance = false,
|
|
2894
|
-
|
|
2550
|
+
scrollCustomFn;
|
|
2895
2551
|
|
|
2552
|
+
// New scroll root, set scrollEl
|
|
2896
2553
|
if (scrollRootEl !== rootEl) {
|
|
2897
2554
|
scrollRootEl = rootEl;
|
|
2898
2555
|
clearAutoScrolls();
|
|
2899
2556
|
scrollEl = options.scroll;
|
|
2900
2557
|
scrollCustomFn = options.scrollFn;
|
|
2901
|
-
|
|
2902
2558
|
if (scrollEl === true) {
|
|
2903
2559
|
scrollEl = getParentAutoScrollElement(rootEl, true);
|
|
2904
2560
|
}
|
|
2905
2561
|
}
|
|
2906
|
-
|
|
2907
2562
|
var layersOut = 0;
|
|
2908
2563
|
var currentParent = scrollEl;
|
|
2909
|
-
|
|
2910
2564
|
do {
|
|
2911
2565
|
var el = currentParent,
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2566
|
+
rect = getRect(el),
|
|
2567
|
+
top = rect.top,
|
|
2568
|
+
bottom = rect.bottom,
|
|
2569
|
+
left = rect.left,
|
|
2570
|
+
right = rect.right,
|
|
2571
|
+
width = rect.width,
|
|
2572
|
+
height = rect.height,
|
|
2573
|
+
canScrollX = void 0,
|
|
2574
|
+
canScrollY = void 0,
|
|
2575
|
+
scrollWidth = el.scrollWidth,
|
|
2576
|
+
scrollHeight = el.scrollHeight,
|
|
2577
|
+
elCSS = css(el),
|
|
2578
|
+
scrollPosX = el.scrollLeft,
|
|
2579
|
+
scrollPosY = el.scrollTop;
|
|
2927
2580
|
if (el === winScroller) {
|
|
2928
2581
|
canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
|
|
2929
2582
|
canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
|
|
@@ -2931,10 +2584,8 @@
|
|
|
2931
2584
|
canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
|
|
2932
2585
|
canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
|
|
2933
2586
|
}
|
|
2934
|
-
|
|
2935
2587
|
var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
|
|
2936
2588
|
var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
|
|
2937
|
-
|
|
2938
2589
|
if (!autoScrolls[layersOut]) {
|
|
2939
2590
|
for (var i = 0; i <= layersOut; i++) {
|
|
2940
2591
|
if (!autoScrolls[i]) {
|
|
@@ -2942,61 +2593,51 @@
|
|
|
2942
2593
|
}
|
|
2943
2594
|
}
|
|
2944
2595
|
}
|
|
2945
|
-
|
|
2946
2596
|
if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
|
|
2947
2597
|
autoScrolls[layersOut].el = el;
|
|
2948
2598
|
autoScrolls[layersOut].vx = vx;
|
|
2949
2599
|
autoScrolls[layersOut].vy = vy;
|
|
2950
2600
|
clearInterval(autoScrolls[layersOut].pid);
|
|
2951
|
-
|
|
2952
2601
|
if (vx != 0 || vy != 0) {
|
|
2953
2602
|
scrollThisInstance = true;
|
|
2954
2603
|
/* jshint loopfunc:true */
|
|
2955
|
-
|
|
2956
2604
|
autoScrolls[layersOut].pid = setInterval(function () {
|
|
2957
2605
|
// emulate drag over during autoscroll (fallback), emulating native DnD behaviour
|
|
2958
2606
|
if (isFallback && this.layer === 0) {
|
|
2959
2607
|
Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
|
|
2960
|
-
|
|
2961
2608
|
}
|
|
2962
|
-
|
|
2963
2609
|
var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
|
|
2964
2610
|
var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
|
|
2965
|
-
|
|
2966
2611
|
if (typeof scrollCustomFn === 'function') {
|
|
2967
2612
|
if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
|
|
2968
2613
|
return;
|
|
2969
2614
|
}
|
|
2970
2615
|
}
|
|
2971
|
-
|
|
2972
2616
|
scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
|
|
2973
2617
|
}.bind({
|
|
2974
2618
|
layer: layersOut
|
|
2975
2619
|
}), 24);
|
|
2976
2620
|
}
|
|
2977
2621
|
}
|
|
2978
|
-
|
|
2979
2622
|
layersOut++;
|
|
2980
2623
|
} while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
|
|
2981
|
-
|
|
2982
2624
|
scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
|
|
2983
2625
|
}, 30);
|
|
2984
2626
|
|
|
2985
2627
|
var drop = function drop(_ref) {
|
|
2986
2628
|
var originalEvent = _ref.originalEvent,
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2629
|
+
putSortable = _ref.putSortable,
|
|
2630
|
+
dragEl = _ref.dragEl,
|
|
2631
|
+
activeSortable = _ref.activeSortable,
|
|
2632
|
+
dispatchSortableEvent = _ref.dispatchSortableEvent,
|
|
2633
|
+
hideGhostForTarget = _ref.hideGhostForTarget,
|
|
2634
|
+
unhideGhostForTarget = _ref.unhideGhostForTarget;
|
|
2993
2635
|
if (!originalEvent) return;
|
|
2994
2636
|
var toSortable = putSortable || activeSortable;
|
|
2995
2637
|
hideGhostForTarget();
|
|
2996
2638
|
var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
|
|
2997
2639
|
var target = document.elementFromPoint(touch.clientX, touch.clientY);
|
|
2998
2640
|
unhideGhostForTarget();
|
|
2999
|
-
|
|
3000
2641
|
if (toSortable && !toSortable.el.contains(target)) {
|
|
3001
2642
|
dispatchSortableEvent('spill');
|
|
3002
2643
|
this.onSpill({
|
|
@@ -3005,9 +2646,7 @@
|
|
|
3005
2646
|
});
|
|
3006
2647
|
}
|
|
3007
2648
|
};
|
|
3008
|
-
|
|
3009
2649
|
function Revert() {}
|
|
3010
|
-
|
|
3011
2650
|
Revert.prototype = {
|
|
3012
2651
|
startIndex: null,
|
|
3013
2652
|
dragStart: function dragStart(_ref2) {
|
|
@@ -3016,40 +2655,32 @@
|
|
|
3016
2655
|
},
|
|
3017
2656
|
onSpill: function onSpill(_ref3) {
|
|
3018
2657
|
var dragEl = _ref3.dragEl,
|
|
3019
|
-
|
|
2658
|
+
putSortable = _ref3.putSortable;
|
|
3020
2659
|
this.sortable.captureAnimationState();
|
|
3021
|
-
|
|
3022
2660
|
if (putSortable) {
|
|
3023
2661
|
putSortable.captureAnimationState();
|
|
3024
2662
|
}
|
|
3025
|
-
|
|
3026
2663
|
var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
|
|
3027
|
-
|
|
3028
2664
|
if (nextSibling) {
|
|
3029
2665
|
this.sortable.el.insertBefore(dragEl, nextSibling);
|
|
3030
2666
|
} else {
|
|
3031
2667
|
this.sortable.el.appendChild(dragEl);
|
|
3032
2668
|
}
|
|
3033
|
-
|
|
3034
2669
|
this.sortable.animateAll();
|
|
3035
|
-
|
|
3036
2670
|
if (putSortable) {
|
|
3037
2671
|
putSortable.animateAll();
|
|
3038
2672
|
}
|
|
3039
2673
|
},
|
|
3040
2674
|
drop: drop
|
|
3041
2675
|
};
|
|
3042
|
-
|
|
3043
2676
|
_extends(Revert, {
|
|
3044
2677
|
pluginName: 'revertOnSpill'
|
|
3045
2678
|
});
|
|
3046
|
-
|
|
3047
2679
|
function Remove() {}
|
|
3048
|
-
|
|
3049
2680
|
Remove.prototype = {
|
|
3050
2681
|
onSpill: function onSpill(_ref4) {
|
|
3051
2682
|
var dragEl = _ref4.dragEl,
|
|
3052
|
-
|
|
2683
|
+
putSortable = _ref4.putSortable;
|
|
3053
2684
|
var parentSortable = putSortable || this.sortable;
|
|
3054
2685
|
parentSortable.captureAnimationState();
|
|
3055
2686
|
dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
|
|
@@ -3057,20 +2688,17 @@
|
|
|
3057
2688
|
},
|
|
3058
2689
|
drop: drop
|
|
3059
2690
|
};
|
|
3060
|
-
|
|
3061
2691
|
_extends(Remove, {
|
|
3062
2692
|
pluginName: 'removeOnSpill'
|
|
3063
2693
|
});
|
|
3064
2694
|
|
|
3065
2695
|
var lastSwapEl;
|
|
3066
|
-
|
|
3067
2696
|
function SwapPlugin() {
|
|
3068
2697
|
function Swap() {
|
|
3069
2698
|
this.defaults = {
|
|
3070
2699
|
swapClass: 'sortable-swap-highlight'
|
|
3071
2700
|
};
|
|
3072
2701
|
}
|
|
3073
|
-
|
|
3074
2702
|
Swap.prototype = {
|
|
3075
2703
|
dragStart: function dragStart(_ref) {
|
|
3076
2704
|
var dragEl = _ref.dragEl;
|
|
@@ -3078,42 +2706,37 @@
|
|
|
3078
2706
|
},
|
|
3079
2707
|
dragOverValid: function dragOverValid(_ref2) {
|
|
3080
2708
|
var completed = _ref2.completed,
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
2709
|
+
target = _ref2.target,
|
|
2710
|
+
onMove = _ref2.onMove,
|
|
2711
|
+
activeSortable = _ref2.activeSortable,
|
|
2712
|
+
changed = _ref2.changed,
|
|
2713
|
+
cancel = _ref2.cancel;
|
|
3086
2714
|
if (!activeSortable.options.swap) return;
|
|
3087
2715
|
var el = this.sortable.el,
|
|
3088
|
-
|
|
3089
|
-
|
|
2716
|
+
options = this.options;
|
|
3090
2717
|
if (target && target !== el) {
|
|
3091
2718
|
var prevSwapEl = lastSwapEl;
|
|
3092
|
-
|
|
3093
2719
|
if (onMove(target) !== false) {
|
|
3094
2720
|
toggleClass(target, options.swapClass, true);
|
|
3095
2721
|
lastSwapEl = target;
|
|
3096
2722
|
} else {
|
|
3097
2723
|
lastSwapEl = null;
|
|
3098
2724
|
}
|
|
3099
|
-
|
|
3100
2725
|
if (prevSwapEl && prevSwapEl !== lastSwapEl) {
|
|
3101
2726
|
toggleClass(prevSwapEl, options.swapClass, false);
|
|
3102
2727
|
}
|
|
3103
2728
|
}
|
|
3104
|
-
|
|
3105
2729
|
changed();
|
|
3106
2730
|
completed(true);
|
|
3107
2731
|
cancel();
|
|
3108
2732
|
},
|
|
3109
2733
|
drop: function drop(_ref3) {
|
|
3110
2734
|
var activeSortable = _ref3.activeSortable,
|
|
3111
|
-
|
|
3112
|
-
|
|
2735
|
+
putSortable = _ref3.putSortable,
|
|
2736
|
+
dragEl = _ref3.dragEl;
|
|
3113
2737
|
var toSortable = putSortable || this.sortable;
|
|
3114
2738
|
var options = this.options;
|
|
3115
2739
|
lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
|
|
3116
|
-
|
|
3117
2740
|
if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
|
|
3118
2741
|
if (dragEl !== lastSwapEl) {
|
|
3119
2742
|
toSortable.captureAnimationState();
|
|
@@ -3137,38 +2760,34 @@
|
|
|
3137
2760
|
}
|
|
3138
2761
|
});
|
|
3139
2762
|
}
|
|
3140
|
-
|
|
3141
2763
|
function swapNodes(n1, n2) {
|
|
3142
2764
|
var p1 = n1.parentNode,
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
2765
|
+
p2 = n2.parentNode,
|
|
2766
|
+
i1,
|
|
2767
|
+
i2;
|
|
3146
2768
|
if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
|
|
3147
2769
|
i1 = index(n1);
|
|
3148
2770
|
i2 = index(n2);
|
|
3149
|
-
|
|
3150
2771
|
if (p1.isEqualNode(p2) && i1 < i2) {
|
|
3151
2772
|
i2++;
|
|
3152
2773
|
}
|
|
3153
|
-
|
|
3154
2774
|
p1.insertBefore(n2, p1.children[i1]);
|
|
3155
2775
|
p2.insertBefore(n1, p2.children[i2]);
|
|
3156
2776
|
}
|
|
3157
2777
|
|
|
3158
2778
|
var multiDragElements = [],
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
2779
|
+
multiDragClones = [],
|
|
2780
|
+
lastMultiDragSelect,
|
|
2781
|
+
// for selection with modifier key down (SHIFT)
|
|
2782
|
+
multiDragSortable,
|
|
2783
|
+
initialFolding = false,
|
|
2784
|
+
// Initial multi-drag fold when drag started
|
|
2785
|
+
folding = false,
|
|
2786
|
+
// Folding any other time
|
|
2787
|
+
dragStarted = false,
|
|
2788
|
+
dragEl$1,
|
|
2789
|
+
clonesFromRect,
|
|
2790
|
+
clonesHidden;
|
|
3172
2791
|
function MultiDragPlugin() {
|
|
3173
2792
|
function MultiDrag(sortable) {
|
|
3174
2793
|
// Bind all private methods
|
|
@@ -3177,22 +2796,22 @@
|
|
|
3177
2796
|
this[fn] = this[fn].bind(this);
|
|
3178
2797
|
}
|
|
3179
2798
|
}
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
2799
|
+
if (!sortable.options.avoidImplicitDeselect) {
|
|
2800
|
+
if (sortable.options.supportPointer) {
|
|
2801
|
+
on(document, 'pointerup', this._deselectMultiDrag);
|
|
2802
|
+
} else {
|
|
2803
|
+
on(document, 'mouseup', this._deselectMultiDrag);
|
|
2804
|
+
on(document, 'touchend', this._deselectMultiDrag);
|
|
2805
|
+
}
|
|
3186
2806
|
}
|
|
3187
|
-
|
|
3188
2807
|
on(document, 'keydown', this._checkKeyDown);
|
|
3189
2808
|
on(document, 'keyup', this._checkKeyUp);
|
|
3190
2809
|
this.defaults = {
|
|
3191
2810
|
selectedClass: 'sortable-selected',
|
|
3192
2811
|
multiDragKey: null,
|
|
2812
|
+
avoidImplicitDeselect: false,
|
|
3193
2813
|
setData: function setData(dataTransfer, dragEl) {
|
|
3194
2814
|
var data = '';
|
|
3195
|
-
|
|
3196
2815
|
if (multiDragElements.length && multiDragSortable === sortable) {
|
|
3197
2816
|
multiDragElements.forEach(function (multiDragElement, i) {
|
|
3198
2817
|
data += (!i ? '' : ', ') + multiDragElement.textContent;
|
|
@@ -3200,12 +2819,10 @@
|
|
|
3200
2819
|
} else {
|
|
3201
2820
|
data = dragEl.textContent;
|
|
3202
2821
|
}
|
|
3203
|
-
|
|
3204
2822
|
dataTransfer.setData('Text', data);
|
|
3205
2823
|
}
|
|
3206
2824
|
};
|
|
3207
2825
|
}
|
|
3208
|
-
|
|
3209
2826
|
MultiDrag.prototype = {
|
|
3210
2827
|
multiDragKeyDown: false,
|
|
3211
2828
|
isMultiDrag: false,
|
|
@@ -3218,9 +2835,8 @@
|
|
|
3218
2835
|
},
|
|
3219
2836
|
setupClone: function setupClone(_ref2) {
|
|
3220
2837
|
var sortable = _ref2.sortable,
|
|
3221
|
-
|
|
2838
|
+
cancel = _ref2.cancel;
|
|
3222
2839
|
if (!this.isMultiDrag) return;
|
|
3223
|
-
|
|
3224
2840
|
for (var i = 0; i < multiDragElements.length; i++) {
|
|
3225
2841
|
multiDragClones.push(clone(multiDragElements[i]));
|
|
3226
2842
|
multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
|
|
@@ -3229,18 +2845,15 @@
|
|
|
3229
2845
|
toggleClass(multiDragClones[i], this.options.selectedClass, false);
|
|
3230
2846
|
multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
|
|
3231
2847
|
}
|
|
3232
|
-
|
|
3233
2848
|
sortable._hideClone();
|
|
3234
|
-
|
|
3235
2849
|
cancel();
|
|
3236
2850
|
},
|
|
3237
2851
|
clone: function clone(_ref3) {
|
|
3238
2852
|
var sortable = _ref3.sortable,
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
2853
|
+
rootEl = _ref3.rootEl,
|
|
2854
|
+
dispatchSortableEvent = _ref3.dispatchSortableEvent,
|
|
2855
|
+
cancel = _ref3.cancel;
|
|
3242
2856
|
if (!this.isMultiDrag) return;
|
|
3243
|
-
|
|
3244
2857
|
if (!this.options.removeCloneOnHide) {
|
|
3245
2858
|
if (multiDragElements.length && multiDragSortable === sortable) {
|
|
3246
2859
|
insertMultiDragClones(true, rootEl);
|
|
@@ -3251,8 +2864,8 @@
|
|
|
3251
2864
|
},
|
|
3252
2865
|
showClone: function showClone(_ref4) {
|
|
3253
2866
|
var cloneNowShown = _ref4.cloneNowShown,
|
|
3254
|
-
|
|
3255
|
-
|
|
2867
|
+
rootEl = _ref4.rootEl,
|
|
2868
|
+
cancel = _ref4.cancel;
|
|
3256
2869
|
if (!this.isMultiDrag) return;
|
|
3257
2870
|
insertMultiDragClones(false, rootEl);
|
|
3258
2871
|
multiDragClones.forEach(function (clone) {
|
|
@@ -3264,14 +2877,12 @@
|
|
|
3264
2877
|
},
|
|
3265
2878
|
hideClone: function hideClone(_ref5) {
|
|
3266
2879
|
var _this = this;
|
|
3267
|
-
|
|
3268
2880
|
var sortable = _ref5.sortable,
|
|
3269
|
-
|
|
3270
|
-
|
|
2881
|
+
cloneNowHidden = _ref5.cloneNowHidden,
|
|
2882
|
+
cancel = _ref5.cancel;
|
|
3271
2883
|
if (!this.isMultiDrag) return;
|
|
3272
2884
|
multiDragClones.forEach(function (clone) {
|
|
3273
2885
|
css(clone, 'display', 'none');
|
|
3274
|
-
|
|
3275
2886
|
if (_this.options.removeCloneOnHide && clone.parentNode) {
|
|
3276
2887
|
clone.parentNode.removeChild(clone);
|
|
3277
2888
|
}
|
|
@@ -3282,15 +2893,14 @@
|
|
|
3282
2893
|
},
|
|
3283
2894
|
dragStartGlobal: function dragStartGlobal(_ref6) {
|
|
3284
2895
|
var sortable = _ref6.sortable;
|
|
3285
|
-
|
|
3286
2896
|
if (!this.isMultiDrag && multiDragSortable) {
|
|
3287
2897
|
multiDragSortable.multiDrag._deselectMultiDrag();
|
|
3288
2898
|
}
|
|
3289
|
-
|
|
3290
2899
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3291
2900
|
multiDragElement.sortableIndex = index(multiDragElement);
|
|
3292
|
-
});
|
|
2901
|
+
});
|
|
3293
2902
|
|
|
2903
|
+
// Sort multi-drag elements
|
|
3294
2904
|
multiDragElements = multiDragElements.sort(function (a, b) {
|
|
3295
2905
|
return a.sortableIndex - b.sortableIndex;
|
|
3296
2906
|
});
|
|
@@ -3298,10 +2908,8 @@
|
|
|
3298
2908
|
},
|
|
3299
2909
|
dragStarted: function dragStarted(_ref7) {
|
|
3300
2910
|
var _this2 = this;
|
|
3301
|
-
|
|
3302
2911
|
var sortable = _ref7.sortable;
|
|
3303
2912
|
if (!this.isMultiDrag) return;
|
|
3304
|
-
|
|
3305
2913
|
if (this.options.sort) {
|
|
3306
2914
|
// Capture rects,
|
|
3307
2915
|
// hide multi drag elements (by positioning them absolute),
|
|
@@ -3309,8 +2917,8 @@
|
|
|
3309
2917
|
// show multi drag elements,
|
|
3310
2918
|
// animate to rects,
|
|
3311
2919
|
// unset rects & remove from DOM
|
|
3312
|
-
sortable.captureAnimationState();
|
|
3313
2920
|
|
|
2921
|
+
sortable.captureAnimationState();
|
|
3314
2922
|
if (this.options.animation) {
|
|
3315
2923
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3316
2924
|
if (multiDragElement === dragEl$1) return;
|
|
@@ -3325,18 +2933,16 @@
|
|
|
3325
2933
|
initialFolding = true;
|
|
3326
2934
|
}
|
|
3327
2935
|
}
|
|
3328
|
-
|
|
3329
2936
|
sortable.animateAll(function () {
|
|
3330
2937
|
folding = false;
|
|
3331
2938
|
initialFolding = false;
|
|
3332
|
-
|
|
3333
2939
|
if (_this2.options.animation) {
|
|
3334
2940
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3335
2941
|
unsetRect(multiDragElement);
|
|
3336
2942
|
});
|
|
3337
|
-
}
|
|
3338
|
-
|
|
2943
|
+
}
|
|
3339
2944
|
|
|
2945
|
+
// Remove all auxiliary multidrag items from el, if sorting enabled
|
|
3340
2946
|
if (_this2.options.sort) {
|
|
3341
2947
|
removeMultiDragElements();
|
|
3342
2948
|
}
|
|
@@ -3344,9 +2950,8 @@
|
|
|
3344
2950
|
},
|
|
3345
2951
|
dragOver: function dragOver(_ref8) {
|
|
3346
2952
|
var target = _ref8.target,
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
2953
|
+
completed = _ref8.completed,
|
|
2954
|
+
cancel = _ref8.cancel;
|
|
3350
2955
|
if (folding && ~multiDragElements.indexOf(target)) {
|
|
3351
2956
|
completed(false);
|
|
3352
2957
|
cancel();
|
|
@@ -3354,10 +2959,9 @@
|
|
|
3354
2959
|
},
|
|
3355
2960
|
revert: function revert(_ref9) {
|
|
3356
2961
|
var fromSortable = _ref9.fromSortable,
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
2962
|
+
rootEl = _ref9.rootEl,
|
|
2963
|
+
sortable = _ref9.sortable,
|
|
2964
|
+
dragRect = _ref9.dragRect;
|
|
3361
2965
|
if (multiDragElements.length > 1) {
|
|
3362
2966
|
// Setup unfold animation
|
|
3363
2967
|
multiDragElements.forEach(function (multiDragElement) {
|
|
@@ -3375,47 +2979,44 @@
|
|
|
3375
2979
|
},
|
|
3376
2980
|
dragOverCompleted: function dragOverCompleted(_ref10) {
|
|
3377
2981
|
var sortable = _ref10.sortable,
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
2982
|
+
isOwner = _ref10.isOwner,
|
|
2983
|
+
insertion = _ref10.insertion,
|
|
2984
|
+
activeSortable = _ref10.activeSortable,
|
|
2985
|
+
parentEl = _ref10.parentEl,
|
|
2986
|
+
putSortable = _ref10.putSortable;
|
|
3383
2987
|
var options = this.options;
|
|
3384
|
-
|
|
3385
2988
|
if (insertion) {
|
|
3386
2989
|
// Clones must be hidden before folding animation to capture dragRectAbsolute properly
|
|
3387
2990
|
if (isOwner) {
|
|
3388
2991
|
activeSortable._hideClone();
|
|
3389
2992
|
}
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
2993
|
+
initialFolding = false;
|
|
2994
|
+
// If leaving sort:false root, or already folding - Fold to new location
|
|
3393
2995
|
if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
|
|
3394
2996
|
// Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
|
|
3395
2997
|
var dragRectAbsolute = getRect(dragEl$1, false, true, true);
|
|
3396
2998
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3397
2999
|
if (multiDragElement === dragEl$1) return;
|
|
3398
|
-
setRect(multiDragElement, dragRectAbsolute);
|
|
3399
|
-
// while folding, and so that we can capture them again because old sortable will no longer be fromSortable
|
|
3000
|
+
setRect(multiDragElement, dragRectAbsolute);
|
|
3400
3001
|
|
|
3002
|
+
// Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
|
|
3003
|
+
// while folding, and so that we can capture them again because old sortable will no longer be fromSortable
|
|
3401
3004
|
parentEl.appendChild(multiDragElement);
|
|
3402
3005
|
});
|
|
3403
3006
|
folding = true;
|
|
3404
|
-
}
|
|
3405
|
-
|
|
3007
|
+
}
|
|
3406
3008
|
|
|
3009
|
+
// Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
|
|
3407
3010
|
if (!isOwner) {
|
|
3408
3011
|
// Only remove if not folding (folding will remove them anyways)
|
|
3409
3012
|
if (!folding) {
|
|
3410
3013
|
removeMultiDragElements();
|
|
3411
3014
|
}
|
|
3412
|
-
|
|
3413
3015
|
if (multiDragElements.length > 1) {
|
|
3414
3016
|
var clonesHiddenBefore = clonesHidden;
|
|
3017
|
+
activeSortable._showClone(sortable);
|
|
3415
3018
|
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3019
|
+
// Unfold animation for clones if showing from hidden
|
|
3419
3020
|
if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
|
|
3420
3021
|
multiDragClones.forEach(function (clone) {
|
|
3421
3022
|
activeSortable.addAnimationState({
|
|
@@ -3434,12 +3035,11 @@
|
|
|
3434
3035
|
},
|
|
3435
3036
|
dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
|
|
3436
3037
|
var dragRect = _ref11.dragRect,
|
|
3437
|
-
|
|
3438
|
-
|
|
3038
|
+
isOwner = _ref11.isOwner,
|
|
3039
|
+
activeSortable = _ref11.activeSortable;
|
|
3439
3040
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3440
3041
|
multiDragElement.thisAnimationDuration = null;
|
|
3441
3042
|
});
|
|
3442
|
-
|
|
3443
3043
|
if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
|
|
3444
3044
|
clonesFromRect = _extends({}, dragRect);
|
|
3445
3045
|
var dragMatrix = matrix(dragEl$1, true);
|
|
@@ -3455,24 +3055,23 @@
|
|
|
3455
3055
|
},
|
|
3456
3056
|
drop: function drop(_ref12) {
|
|
3457
3057
|
var evt = _ref12.originalEvent,
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3058
|
+
rootEl = _ref12.rootEl,
|
|
3059
|
+
parentEl = _ref12.parentEl,
|
|
3060
|
+
sortable = _ref12.sortable,
|
|
3061
|
+
dispatchSortableEvent = _ref12.dispatchSortableEvent,
|
|
3062
|
+
oldIndex = _ref12.oldIndex,
|
|
3063
|
+
putSortable = _ref12.putSortable;
|
|
3464
3064
|
var toSortable = putSortable || this.sortable;
|
|
3465
3065
|
if (!evt) return;
|
|
3466
3066
|
var options = this.options,
|
|
3467
|
-
|
|
3067
|
+
children = parentEl.children;
|
|
3468
3068
|
|
|
3069
|
+
// Multi-drag selection
|
|
3469
3070
|
if (!dragStarted) {
|
|
3470
3071
|
if (options.multiDragKey && !this.multiDragKeyDown) {
|
|
3471
3072
|
this._deselectMultiDrag();
|
|
3472
3073
|
}
|
|
3473
|
-
|
|
3474
3074
|
toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
|
|
3475
|
-
|
|
3476
3075
|
if (!~multiDragElements.indexOf(dragEl$1)) {
|
|
3477
3076
|
multiDragElements.push(dragEl$1);
|
|
3478
3077
|
dispatchEvent({
|
|
@@ -3480,18 +3079,17 @@
|
|
|
3480
3079
|
rootEl: rootEl,
|
|
3481
3080
|
name: 'select',
|
|
3482
3081
|
targetEl: dragEl$1,
|
|
3483
|
-
|
|
3484
|
-
});
|
|
3082
|
+
originalEvent: evt
|
|
3083
|
+
});
|
|
3485
3084
|
|
|
3085
|
+
// Modifier activated, select from last to dragEl
|
|
3486
3086
|
if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
|
|
3487
3087
|
var lastIndex = index(lastMultiDragSelect),
|
|
3488
|
-
|
|
3489
|
-
|
|
3088
|
+
currentIndex = index(dragEl$1);
|
|
3490
3089
|
if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
|
|
3491
3090
|
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
|
|
3492
3091
|
// (but previous selection existed)
|
|
3493
3092
|
var n, i;
|
|
3494
|
-
|
|
3495
3093
|
if (currentIndex > lastIndex) {
|
|
3496
3094
|
i = lastIndex;
|
|
3497
3095
|
n = currentIndex;
|
|
@@ -3499,7 +3097,6 @@
|
|
|
3499
3097
|
i = currentIndex;
|
|
3500
3098
|
n = lastIndex + 1;
|
|
3501
3099
|
}
|
|
3502
|
-
|
|
3503
3100
|
for (; i < n; i++) {
|
|
3504
3101
|
if (~multiDragElements.indexOf(children[i])) continue;
|
|
3505
3102
|
toggleClass(children[i], options.selectedClass, true);
|
|
@@ -3509,14 +3106,13 @@
|
|
|
3509
3106
|
rootEl: rootEl,
|
|
3510
3107
|
name: 'select',
|
|
3511
3108
|
targetEl: children[i],
|
|
3512
|
-
|
|
3109
|
+
originalEvent: evt
|
|
3513
3110
|
});
|
|
3514
3111
|
}
|
|
3515
3112
|
}
|
|
3516
3113
|
} else {
|
|
3517
3114
|
lastMultiDragSelect = dragEl$1;
|
|
3518
3115
|
}
|
|
3519
|
-
|
|
3520
3116
|
multiDragSortable = toSortable;
|
|
3521
3117
|
} else {
|
|
3522
3118
|
multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
|
|
@@ -3526,41 +3122,40 @@
|
|
|
3526
3122
|
rootEl: rootEl,
|
|
3527
3123
|
name: 'deselect',
|
|
3528
3124
|
targetEl: dragEl$1,
|
|
3529
|
-
|
|
3125
|
+
originalEvent: evt
|
|
3530
3126
|
});
|
|
3531
3127
|
}
|
|
3532
|
-
}
|
|
3533
|
-
|
|
3128
|
+
}
|
|
3534
3129
|
|
|
3130
|
+
// Multi-drag drop
|
|
3535
3131
|
if (dragStarted && this.isMultiDrag) {
|
|
3536
|
-
folding = false;
|
|
3537
|
-
|
|
3132
|
+
folding = false;
|
|
3133
|
+
// Do not "unfold" after around dragEl if reverted
|
|
3538
3134
|
if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
|
|
3539
3135
|
var dragRect = getRect(dragEl$1),
|
|
3540
|
-
|
|
3136
|
+
multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')');
|
|
3541
3137
|
if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
|
|
3542
3138
|
toSortable.captureAnimationState();
|
|
3543
|
-
|
|
3544
3139
|
if (!initialFolding) {
|
|
3545
3140
|
if (options.animation) {
|
|
3546
3141
|
dragEl$1.fromRect = dragRect;
|
|
3547
3142
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3548
3143
|
multiDragElement.thisAnimationDuration = null;
|
|
3549
|
-
|
|
3550
3144
|
if (multiDragElement !== dragEl$1) {
|
|
3551
3145
|
var rect = folding ? getRect(multiDragElement) : dragRect;
|
|
3552
|
-
multiDragElement.fromRect = rect;
|
|
3146
|
+
multiDragElement.fromRect = rect;
|
|
3553
3147
|
|
|
3148
|
+
// Prepare unfold animation
|
|
3554
3149
|
toSortable.addAnimationState({
|
|
3555
3150
|
target: multiDragElement,
|
|
3556
3151
|
rect: rect
|
|
3557
3152
|
});
|
|
3558
3153
|
}
|
|
3559
3154
|
});
|
|
3560
|
-
}
|
|
3561
|
-
// properly they must all be removed
|
|
3562
|
-
|
|
3155
|
+
}
|
|
3563
3156
|
|
|
3157
|
+
// Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
|
|
3158
|
+
// properly they must all be removed
|
|
3564
3159
|
removeMultiDragElements();
|
|
3565
3160
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3566
3161
|
if (children[multiDragIndex]) {
|
|
@@ -3568,12 +3163,12 @@
|
|
|
3568
3163
|
} else {
|
|
3569
3164
|
parentEl.appendChild(multiDragElement);
|
|
3570
3165
|
}
|
|
3571
|
-
|
|
3572
3166
|
multiDragIndex++;
|
|
3573
|
-
});
|
|
3167
|
+
});
|
|
3168
|
+
|
|
3169
|
+
// If initial folding is done, the elements may have changed position because they are now
|
|
3574
3170
|
// unfolding around dragEl, even though dragEl may not have his index changed, so update event
|
|
3575
3171
|
// must be fired here as Sortable will not.
|
|
3576
|
-
|
|
3577
3172
|
if (oldIndex === index(dragEl$1)) {
|
|
3578
3173
|
var update = false;
|
|
3579
3174
|
multiDragElements.forEach(function (multiDragElement) {
|
|
@@ -3582,24 +3177,23 @@
|
|
|
3582
3177
|
return;
|
|
3583
3178
|
}
|
|
3584
3179
|
});
|
|
3585
|
-
|
|
3586
3180
|
if (update) {
|
|
3587
3181
|
dispatchSortableEvent('update');
|
|
3182
|
+
dispatchSortableEvent('sort');
|
|
3588
3183
|
}
|
|
3589
3184
|
}
|
|
3590
|
-
}
|
|
3591
|
-
|
|
3185
|
+
}
|
|
3592
3186
|
|
|
3187
|
+
// Must be done after capturing individual rects (scroll bar)
|
|
3593
3188
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3594
3189
|
unsetRect(multiDragElement);
|
|
3595
3190
|
});
|
|
3596
3191
|
toSortable.animateAll();
|
|
3597
3192
|
}
|
|
3598
|
-
|
|
3599
3193
|
multiDragSortable = toSortable;
|
|
3600
|
-
}
|
|
3601
|
-
|
|
3194
|
+
}
|
|
3602
3195
|
|
|
3196
|
+
// Remove clones if necessary
|
|
3603
3197
|
if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
|
|
3604
3198
|
multiDragClones.forEach(function (clone) {
|
|
3605
3199
|
clone.parentNode && clone.parentNode.removeChild(clone);
|
|
@@ -3612,7 +3206,6 @@
|
|
|
3612
3206
|
},
|
|
3613
3207
|
destroyGlobal: function destroyGlobal() {
|
|
3614
3208
|
this._deselectMultiDrag();
|
|
3615
|
-
|
|
3616
3209
|
off(document, 'pointerup', this._deselectMultiDrag);
|
|
3617
3210
|
off(document, 'mouseup', this._deselectMultiDrag);
|
|
3618
3211
|
off(document, 'touchend', this._deselectMultiDrag);
|
|
@@ -3620,14 +3213,16 @@
|
|
|
3620
3213
|
off(document, 'keyup', this._checkKeyUp);
|
|
3621
3214
|
},
|
|
3622
3215
|
_deselectMultiDrag: function _deselectMultiDrag(evt) {
|
|
3623
|
-
if (typeof dragStarted !== "undefined" && dragStarted) return;
|
|
3216
|
+
if (typeof dragStarted !== "undefined" && dragStarted) return;
|
|
3624
3217
|
|
|
3625
|
-
|
|
3218
|
+
// Only deselect if selection is in this sortable
|
|
3219
|
+
if (multiDragSortable !== this.sortable) return;
|
|
3626
3220
|
|
|
3627
|
-
|
|
3221
|
+
// Only deselect if target is not item in this sortable
|
|
3222
|
+
if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return;
|
|
3628
3223
|
|
|
3224
|
+
// Only deselect if left click
|
|
3629
3225
|
if (evt && evt.button !== 0) return;
|
|
3630
|
-
|
|
3631
3226
|
while (multiDragElements.length) {
|
|
3632
3227
|
var el = multiDragElements[0];
|
|
3633
3228
|
toggleClass(el, this.options.selectedClass, false);
|
|
@@ -3637,7 +3232,7 @@
|
|
|
3637
3232
|
rootEl: this.sortable.el,
|
|
3638
3233
|
name: 'deselect',
|
|
3639
3234
|
targetEl: el,
|
|
3640
|
-
|
|
3235
|
+
originalEvent: evt
|
|
3641
3236
|
});
|
|
3642
3237
|
}
|
|
3643
3238
|
},
|
|
@@ -3656,31 +3251,27 @@
|
|
|
3656
3251
|
// Static methods & properties
|
|
3657
3252
|
pluginName: 'multiDrag',
|
|
3658
3253
|
utils: {
|
|
3659
|
-
/**
|
|
3660
|
-
* Selects the provided multi-drag item
|
|
3661
|
-
* @param {HTMLElement} el The element to be selected
|
|
3254
|
+
/**
|
|
3255
|
+
* Selects the provided multi-drag item
|
|
3256
|
+
* @param {HTMLElement} el The element to be selected
|
|
3662
3257
|
*/
|
|
3663
3258
|
select: function select(el) {
|
|
3664
3259
|
var sortable = el.parentNode[expando];
|
|
3665
3260
|
if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return;
|
|
3666
|
-
|
|
3667
3261
|
if (multiDragSortable && multiDragSortable !== sortable) {
|
|
3668
3262
|
multiDragSortable.multiDrag._deselectMultiDrag();
|
|
3669
|
-
|
|
3670
3263
|
multiDragSortable = sortable;
|
|
3671
3264
|
}
|
|
3672
|
-
|
|
3673
3265
|
toggleClass(el, sortable.options.selectedClass, true);
|
|
3674
3266
|
multiDragElements.push(el);
|
|
3675
3267
|
},
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
*
|
|
3679
|
-
* @param {HTMLElement} el The element to be deselected
|
|
3268
|
+
/**
|
|
3269
|
+
* Deselects the provided multi-drag item
|
|
3270
|
+
* @param {HTMLElement} el The element to be deselected
|
|
3680
3271
|
*/
|
|
3681
3272
|
deselect: function deselect(el) {
|
|
3682
3273
|
var sortable = el.parentNode[expando],
|
|
3683
|
-
|
|
3274
|
+
index = multiDragElements.indexOf(el);
|
|
3684
3275
|
if (!sortable || !sortable.options.multiDrag || !~index) return;
|
|
3685
3276
|
toggleClass(el, sortable.options.selectedClass, false);
|
|
3686
3277
|
multiDragElements.splice(index, 1);
|
|
@@ -3688,17 +3279,16 @@
|
|
|
3688
3279
|
},
|
|
3689
3280
|
eventProperties: function eventProperties() {
|
|
3690
3281
|
var _this3 = this;
|
|
3691
|
-
|
|
3692
3282
|
var oldIndicies = [],
|
|
3693
|
-
|
|
3283
|
+
newIndicies = [];
|
|
3694
3284
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3695
3285
|
oldIndicies.push({
|
|
3696
3286
|
multiDragElement: multiDragElement,
|
|
3697
3287
|
index: multiDragElement.sortableIndex
|
|
3698
|
-
});
|
|
3288
|
+
});
|
|
3699
3289
|
|
|
3290
|
+
// multiDragElements will already be sorted if folding
|
|
3700
3291
|
var newIndex;
|
|
3701
|
-
|
|
3702
3292
|
if (folding && multiDragElement !== dragEl$1) {
|
|
3703
3293
|
newIndex = -1;
|
|
3704
3294
|
} else if (folding) {
|
|
@@ -3706,7 +3296,6 @@
|
|
|
3706
3296
|
} else {
|
|
3707
3297
|
newIndex = index(multiDragElement);
|
|
3708
3298
|
}
|
|
3709
|
-
|
|
3710
3299
|
newIndicies.push({
|
|
3711
3300
|
multiDragElement: multiDragElement,
|
|
3712
3301
|
index: newIndex
|
|
@@ -3722,23 +3311,19 @@
|
|
|
3722
3311
|
optionListeners: {
|
|
3723
3312
|
multiDragKey: function multiDragKey(key) {
|
|
3724
3313
|
key = key.toLowerCase();
|
|
3725
|
-
|
|
3726
3314
|
if (key === 'ctrl') {
|
|
3727
3315
|
key = 'Control';
|
|
3728
3316
|
} else if (key.length > 1) {
|
|
3729
3317
|
key = key.charAt(0).toUpperCase() + key.substr(1);
|
|
3730
3318
|
}
|
|
3731
|
-
|
|
3732
3319
|
return key;
|
|
3733
3320
|
}
|
|
3734
3321
|
}
|
|
3735
3322
|
});
|
|
3736
3323
|
}
|
|
3737
|
-
|
|
3738
3324
|
function insertMultiDragElements(clonesInserted, rootEl) {
|
|
3739
3325
|
multiDragElements.forEach(function (multiDragElement, i) {
|
|
3740
3326
|
var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
|
|
3741
|
-
|
|
3742
3327
|
if (target) {
|
|
3743
3328
|
rootEl.insertBefore(multiDragElement, target);
|
|
3744
3329
|
} else {
|
|
@@ -3746,17 +3331,15 @@
|
|
|
3746
3331
|
}
|
|
3747
3332
|
});
|
|
3748
3333
|
}
|
|
3749
|
-
/**
|
|
3750
|
-
* Insert multi-drag clones
|
|
3751
|
-
* @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
|
|
3752
|
-
* @param {HTMLElement} rootEl
|
|
3753
|
-
*/
|
|
3754
|
-
|
|
3755
3334
|
|
|
3335
|
+
/**
|
|
3336
|
+
* Insert multi-drag clones
|
|
3337
|
+
* @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
|
|
3338
|
+
* @param {HTMLElement} rootEl
|
|
3339
|
+
*/
|
|
3756
3340
|
function insertMultiDragClones(elementsInserted, rootEl) {
|
|
3757
3341
|
multiDragClones.forEach(function (clone, i) {
|
|
3758
3342
|
var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
|
|
3759
|
-
|
|
3760
3343
|
if (target) {
|
|
3761
3344
|
rootEl.insertBefore(clone, target);
|
|
3762
3345
|
} else {
|
|
@@ -3764,7 +3347,6 @@
|
|
|
3764
3347
|
}
|
|
3765
3348
|
});
|
|
3766
3349
|
}
|
|
3767
|
-
|
|
3768
3350
|
function removeMultiDragElements() {
|
|
3769
3351
|
multiDragElements.forEach(function (multiDragElement) {
|
|
3770
3352
|
if (multiDragElement === dragEl$1) return;
|