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