sortablejs 1.14.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**!
2
- * Sortable 1.14.0
2
+ * Sortable 1.15.0
3
3
  * @author RubaXa <trash@rubaxa.org>
4
4
  * @author owenm <owen23355@gmail.com>
5
5
  * @license MIT
@@ -160,7 +160,7 @@ function _nonIterableSpread() {
160
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.");
161
161
  }
162
162
 
163
- var version = "1.14.0";
163
+ var version = "1.15.0";
164
164
 
165
165
  function userAgent(pattern) {
166
166
  if (typeof window !== 'undefined' && window.navigator) {
@@ -1097,11 +1097,11 @@ supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in
1097
1097
  return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
1098
1098
  },
1099
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
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
1105
  */
1106
1106
  _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
1107
1107
  var ret;
@@ -1167,7 +1167,7 @@ _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
1167
1167
  }; // #1184 fix - Prevent click event on fallback if dragged but item not changed position
1168
1168
 
1169
1169
 
1170
- if (documentExists) {
1170
+ if (documentExists && !ChromeForAndroid) {
1171
1171
  document.addEventListener('click', function (evt) {
1172
1172
  if (ignoreNextClick) {
1173
1173
  evt.preventDefault();
@@ -1209,10 +1209,10 @@ var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
1209
1209
  dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1210
1210
  }
1211
1211
  };
1212
- /**
1213
- * @class Sortable
1214
- * @param {HTMLElement} el
1215
- * @param {Object} [options]
1212
+ /**
1213
+ * @class Sortable
1214
+ * @param {HTMLElement} el
1215
+ * @param {Object} [options]
1216
1216
  */
1217
1217
 
1218
1218
 
@@ -1786,6 +1786,7 @@ Sortable.prototype =
1786
1786
 
1787
1787
  if (!Sortable.eventCanceled) {
1788
1788
  cloneEl = clone(dragEl);
1789
+ cloneEl.removeAttribute("id");
1789
1790
  cloneEl.draggable = false;
1790
1791
  cloneEl.style['will-change'] = '';
1791
1792
 
@@ -2027,7 +2028,14 @@ Sortable.prototype =
2027
2028
 
2028
2029
  if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
2029
2030
  capture();
2030
- el.appendChild(dragEl);
2031
+
2032
+ if (elLastChild && elLastChild.nextSibling) {
2033
+ // the last draggable element is not the last node
2034
+ el.insertBefore(dragEl, elLastChild.nextSibling);
2035
+ } else {
2036
+ el.appendChild(dragEl);
2037
+ }
2038
+
2031
2039
  parentEl = el; // actualization
2032
2040
 
2033
2041
  changed();
@@ -2350,9 +2358,9 @@ Sortable.prototype =
2350
2358
  }
2351
2359
  },
2352
2360
 
2353
- /**
2354
- * Serializes the item into an array of string.
2355
- * @returns {String[]}
2361
+ /**
2362
+ * Serializes the item into an array of string.
2363
+ * @returns {String[]}
2356
2364
  */
2357
2365
  toArray: function toArray() {
2358
2366
  var order = [],
@@ -2373,9 +2381,9 @@ Sortable.prototype =
2373
2381
  return order;
2374
2382
  },
2375
2383
 
2376
- /**
2377
- * Sorts the elements according to the array.
2378
- * @param {String[]} order order of the items
2384
+ /**
2385
+ * Sorts the elements according to the array.
2386
+ * @param {String[]} order order of the items
2379
2387
  */
2380
2388
  sort: function sort(order, useAnimation) {
2381
2389
  var items = {},
@@ -2397,29 +2405,29 @@ Sortable.prototype =
2397
2405
  useAnimation && this.animateAll();
2398
2406
  },
2399
2407
 
2400
- /**
2401
- * Save the current sorting
2408
+ /**
2409
+ * Save the current sorting
2402
2410
  */
2403
2411
  save: function save() {
2404
2412
  var store = this.options.store;
2405
2413
  store && store.set && store.set(this);
2406
2414
  },
2407
2415
 
2408
- /**
2409
- * 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.
2410
- * @param {HTMLElement} el
2411
- * @param {String} [selector] default: `options.draggable`
2412
- * @returns {HTMLElement|null}
2416
+ /**
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.
2418
+ * @param {HTMLElement} el
2419
+ * @param {String} [selector] default: `options.draggable`
2420
+ * @returns {HTMLElement|null}
2413
2421
  */
2414
2422
  closest: function closest$1(el, selector) {
2415
2423
  return closest(el, selector || this.options.draggable, this.el, false);
2416
2424
  },
2417
2425
 
2418
- /**
2419
- * Set/get option
2420
- * @param {string} name
2421
- * @param {*} [value]
2422
- * @returns {*}
2426
+ /**
2427
+ * Set/get option
2428
+ * @param {string} name
2429
+ * @param {*} [value]
2430
+ * @returns {*}
2423
2431
  */
2424
2432
  option: function option(name, value) {
2425
2433
  var options = this.options;
@@ -2441,8 +2449,8 @@ Sortable.prototype =
2441
2449
  }
2442
2450
  },
2443
2451
 
2444
- /**
2445
- * Destroy
2452
+ /**
2453
+ * Destroy
2446
2454
  */
2447
2455
  destroy: function destroy() {
2448
2456
  pluginEvent('destroy', this);
@@ -2619,11 +2627,11 @@ function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, inv
2619
2627
 
2620
2628
  return 0;
2621
2629
  }
2622
- /**
2623
- * Gets the direction dragEl must be swapped relative to target in order to make it
2624
- * seem that dragEl has been "inserted" into that element's position
2625
- * @param {HTMLElement} target The target whose position dragEl is being inserted at
2626
- * @return {Number} Direction dragEl must be swapped
2630
+ /**
2631
+ * Gets the direction dragEl must be swapped relative to target in order to make it
2632
+ * seem that dragEl has been "inserted" into that element's position
2633
+ * @param {HTMLElement} target The target whose position dragEl is being inserted at
2634
+ * @return {Number} Direction dragEl must be swapped
2627
2635
  */
2628
2636
 
2629
2637
 
@@ -2634,11 +2642,11 @@ function _getInsertDirection(target) {
2634
2642
  return -1;
2635
2643
  }
2636
2644
  }
2637
- /**
2638
- * Generate id
2639
- * @param {HTMLElement} el
2640
- * @returns {String}
2641
- * @private
2645
+ /**
2646
+ * Generate id
2647
+ * @param {HTMLElement} el
2648
+ * @returns {String}
2649
+ * @private
2642
2650
  */
2643
2651
 
2644
2652
 
@@ -2702,18 +2710,18 @@ Sortable.utils = {
2702
2710
  detectDirection: _detectDirection,
2703
2711
  getChild: getChild
2704
2712
  };
2705
- /**
2706
- * Get the Sortable instance of an element
2707
- * @param {HTMLElement} element The element
2708
- * @return {Sortable|undefined} The instance of Sortable
2713
+ /**
2714
+ * Get the Sortable instance of an element
2715
+ * @param {HTMLElement} element The element
2716
+ * @return {Sortable|undefined} The instance of Sortable
2709
2717
  */
2710
2718
 
2711
2719
  Sortable.get = function (element) {
2712
2720
  return element[expando];
2713
2721
  };
2714
- /**
2715
- * Mount a plugin to Sortable
2716
- * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
2722
+ /**
2723
+ * Mount a plugin to Sortable
2724
+ * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
2717
2725
  */
2718
2726
 
2719
2727
 
@@ -2732,10 +2740,10 @@ Sortable.mount = function () {
2732
2740
  PluginManager.mount(plugin);
2733
2741
  });
2734
2742
  };
2735
- /**
2736
- * Create sortable instance
2737
- * @param {HTMLElement} el
2738
- * @param {Object} [options]
2743
+ /**
2744
+ * Create sortable instance
2745
+ * @param {HTMLElement} el
2746
+ * @param {Object} [options]
2739
2747
  */
2740
2748
 
2741
2749
 
@@ -3172,11 +3180,13 @@ function MultiDragPlugin() {
3172
3180
  }
3173
3181
  }
3174
3182
 
3175
- if (sortable.options.supportPointer) {
3176
- on(document, 'pointerup', this._deselectMultiDrag);
3177
- } else {
3178
- on(document, 'mouseup', this._deselectMultiDrag);
3179
- on(document, 'touchend', this._deselectMultiDrag);
3183
+ if (!sortable.options.avoidImplicitDeselect) {
3184
+ if (sortable.options.supportPointer) {
3185
+ on(document, 'pointerup', this._deselectMultiDrag);
3186
+ } else {
3187
+ on(document, 'mouseup', this._deselectMultiDrag);
3188
+ on(document, 'touchend', this._deselectMultiDrag);
3189
+ }
3180
3190
  }
3181
3191
 
3182
3192
  on(document, 'keydown', this._checkKeyDown);
@@ -3184,6 +3194,7 @@ function MultiDragPlugin() {
3184
3194
  this.defaults = {
3185
3195
  selectedClass: 'sortable-selected',
3186
3196
  multiDragKey: null,
3197
+ avoidImplicitDeselect: false,
3187
3198
  setData: function setData(dataTransfer, dragEl) {
3188
3199
  var data = '';
3189
3200
 
@@ -3474,7 +3485,7 @@ function MultiDragPlugin() {
3474
3485
  rootEl: rootEl,
3475
3486
  name: 'select',
3476
3487
  targetEl: dragEl$1,
3477
- originalEvt: evt
3488
+ originalEvent: evt
3478
3489
  }); // Modifier activated, select from last to dragEl
3479
3490
 
3480
3491
  if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
@@ -3503,7 +3514,7 @@ function MultiDragPlugin() {
3503
3514
  rootEl: rootEl,
3504
3515
  name: 'select',
3505
3516
  targetEl: children[i],
3506
- originalEvt: evt
3517
+ originalEvent: evt
3507
3518
  });
3508
3519
  }
3509
3520
  }
@@ -3520,7 +3531,7 @@ function MultiDragPlugin() {
3520
3531
  rootEl: rootEl,
3521
3532
  name: 'deselect',
3522
3533
  targetEl: dragEl$1,
3523
- originalEvt: evt
3534
+ originalEvent: evt
3524
3535
  });
3525
3536
  }
3526
3537
  } // Multi-drag drop
@@ -3631,7 +3642,7 @@ function MultiDragPlugin() {
3631
3642
  rootEl: this.sortable.el,
3632
3643
  name: 'deselect',
3633
3644
  targetEl: el,
3634
- originalEvt: evt
3645
+ originalEvent: evt
3635
3646
  });
3636
3647
  }
3637
3648
  },
@@ -3650,9 +3661,9 @@ function MultiDragPlugin() {
3650
3661
  // Static methods & properties
3651
3662
  pluginName: 'multiDrag',
3652
3663
  utils: {
3653
- /**
3654
- * Selects the provided multi-drag item
3655
- * @param {HTMLElement} el The element to be selected
3664
+ /**
3665
+ * Selects the provided multi-drag item
3666
+ * @param {HTMLElement} el The element to be selected
3656
3667
  */
3657
3668
  select: function select(el) {
3658
3669
  var sortable = el.parentNode[expando];
@@ -3668,9 +3679,9 @@ function MultiDragPlugin() {
3668
3679
  multiDragElements.push(el);
3669
3680
  },
3670
3681
 
3671
- /**
3672
- * Deselects the provided multi-drag item
3673
- * @param {HTMLElement} el The element to be deselected
3682
+ /**
3683
+ * Deselects the provided multi-drag item
3684
+ * @param {HTMLElement} el The element to be deselected
3674
3685
  */
3675
3686
  deselect: function deselect(el) {
3676
3687
  var sortable = el.parentNode[expando],
@@ -3740,10 +3751,10 @@ function insertMultiDragElements(clonesInserted, rootEl) {
3740
3751
  }
3741
3752
  });
3742
3753
  }
3743
- /**
3744
- * Insert multi-drag clones
3745
- * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
3746
- * @param {HTMLElement} rootEl
3754
+ /**
3755
+ * Insert multi-drag clones
3756
+ * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
3757
+ * @param {HTMLElement} rootEl
3747
3758
  */
3748
3759
 
3749
3760
 
package/package.json CHANGED
@@ -1,56 +1,56 @@
1
- {
2
- "name": "sortablejs",
3
- "exportName": "Sortable",
4
- "version": "1.14.0",
5
- "devDependencies": {
6
- "@babel/core": "^7.4.4",
7
- "@babel/plugin-transform-object-assign": "^7.2.0",
8
- "@babel/preset-env": "^7.4.4",
9
- "rollup": "^1.11.3",
10
- "rollup-plugin-babel": "^4.3.2",
11
- "rollup-plugin-json": "^4.0.0",
12
- "rollup-plugin-node-resolve": "^5.0.0",
13
- "testcafe": "^1.3.1",
14
- "testcafe-browser-provider-saucelabs": "^1.7.0",
15
- "testcafe-reporter-xunit": "^2.1.0",
16
- "uglify-js": "^3.5.12"
17
- },
18
- "description": "JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery required. Supports Meteor, AngularJS, React, Polymer, Vue, Knockout and any CSS library, e.g. Bootstrap.",
19
- "main": "./Sortable.min.js",
20
- "module": "modular/sortable.esm.js",
21
- "scripts": {
22
- "build:umd": "NODE_ENV=umd rollup -c ./scripts/umd-build.js",
23
- "build:umd:watch": "set NODE_ENV=umd&& rollup -w -c ./scripts/umd-build.js",
24
- "build:es": "set NODE_ENV=es&& rollup -c ./scripts/esm-build.js",
25
- "build:es:watch": "set NODE_ENV=es&& rollup -w -c ./scripts/esm-build.js",
26
- "minify": "node ./scripts/minify.js",
27
- "build": "npm run build:es && npm run build:umd && npm run minify",
28
- "test:compat": "node ./scripts/test-compat.js",
29
- "test": "node ./scripts/test.js"
30
- },
31
- "maintainers": [
32
- "Konstantin Lebedev <ibnRubaXa@gmail.com>",
33
- "Owen Mills <owen23355@gmail.com>"
34
- ],
35
- "repository": {
36
- "type": "git",
37
- "url": "git://github.com/SortableJS/Sortable.git"
38
- },
39
- "files": [
40
- "Sortable.js",
41
- "Sortable.min.js",
42
- "modular/"
43
- ],
44
- "keywords": [
45
- "sortable",
46
- "reorder",
47
- "drag",
48
- "meteor",
49
- "angular",
50
- "ng-sortable",
51
- "react",
52
- "vue",
53
- "mixin"
54
- ],
55
- "license": "MIT"
56
- }
1
+ {
2
+ "name": "sortablejs",
3
+ "exportName": "Sortable",
4
+ "version": "1.15.0",
5
+ "devDependencies": {
6
+ "@babel/core": "^7.4.4",
7
+ "@babel/plugin-transform-object-assign": "^7.2.0",
8
+ "@babel/preset-env": "^7.4.4",
9
+ "rollup": "^1.11.3",
10
+ "rollup-plugin-babel": "^4.3.2",
11
+ "rollup-plugin-json": "^4.0.0",
12
+ "rollup-plugin-node-resolve": "^5.0.0",
13
+ "testcafe": "^1.3.1",
14
+ "testcafe-browser-provider-saucelabs": "^1.7.0",
15
+ "testcafe-reporter-xunit": "^2.1.0",
16
+ "uglify-js": "^3.5.12"
17
+ },
18
+ "description": "JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery required. Supports Meteor, AngularJS, React, Polymer, Vue, Knockout and any CSS library, e.g. Bootstrap.",
19
+ "main": "./Sortable.min.js",
20
+ "module": "modular/sortable.esm.js",
21
+ "scripts": {
22
+ "build:umd": "set NODE_ENV=umd&& rollup -c ./scripts/umd-build.js",
23
+ "build:umd:watch": "set NODE_ENV=umd&& rollup -w -c ./scripts/umd-build.js",
24
+ "build:es": "set NODE_ENV=es&& rollup -c ./scripts/esm-build.js",
25
+ "build:es:watch": "set NODE_ENV=es&& rollup -w -c ./scripts/esm-build.js",
26
+ "minify": "node ./scripts/minify.js",
27
+ "build": "npm run build:es && npm run build:umd && npm run minify",
28
+ "test:compat": "node ./scripts/test-compat.js",
29
+ "test": "node ./scripts/test.js"
30
+ },
31
+ "maintainers": [
32
+ "Konstantin Lebedev <ibnRubaXa@gmail.com>",
33
+ "Owen Mills <owen23355@gmail.com>"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git://github.com/SortableJS/Sortable.git"
38
+ },
39
+ "files": [
40
+ "Sortable.js",
41
+ "Sortable.min.js",
42
+ "modular/"
43
+ ],
44
+ "keywords": [
45
+ "sortable",
46
+ "reorder",
47
+ "drag",
48
+ "meteor",
49
+ "angular",
50
+ "ng-sortable",
51
+ "react",
52
+ "vue",
53
+ "mixin"
54
+ ],
55
+ "license": "MIT"
56
+ }