Browse Source

Merge branch 'master' into master

pull/1205/head
Lebedev Konstantin 7 years ago committed by GitHub
parent
commit
06204668a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      README.md
  2. 75
      Sortable.js
  3. 4
      Sortable.min.js
  4. 2
      component.json
  5. 2
      package.json

10
README.md

@ -102,7 +102,7 @@ var sortable = new Sortable(el, {
fallbackTolerance: 0, // Specify in pixels how far the mouse should move before it's considered as a drag. fallbackTolerance: 0, // Specify in pixels how far the mouse should move before it's considered as a drag.
scroll: true, // or HTMLElement scroll: true, // or HTMLElement
scrollFn: function(offsetX, offsetY, originalEvent) { ... }, // if you have custom scrollbar scrollFn may be used for autoscrolling scrollFn: function(offsetX, offsetY, originalEvent, touchEvt, hoverTargetEl) { ... }, // if you have custom scrollbar scrollFn may be used for autoscrolling
scrollSensitivity: 30, // px, how near the mouse must be to an edge to start scrolling. scrollSensitivity: 30, // px, how near the mouse must be to an edge to start scrolling.
scrollSpeed: 10, // px scrollSpeed: 10, // px
@ -576,12 +576,12 @@ Link to the active instance.
### CDN ### CDN
```html ```html
<!-- jsDelivr :: Sortable (http://www.jsdelivr.com/package/npm/sortablejs) --> <!-- jsDelivr :: Sortable (https://www.jsdelivr.com/package/npm/sortablejs) -->
<script src="//cdn.jsdelivr.net/npm/sortablejs@1.6.1/Sortable.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.6.1/Sortable.min.js"></script>
<!-- jsDelivr :: Sortable :: Latest (http://www.jsdelivr.com/package/npm/sortablejs) --> <!-- jsDelivr :: Sortable :: Latest (https://www.jsdelivr.com/package/npm/sortablejs) -->
<script src="//cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
``` ```

75
Sortable.js

@ -55,6 +55,8 @@
moved, moved,
forRepaintDummy,
/** @const */ /** @const */
R_SPACE = /\s+/g, R_SPACE = /\s+/g,
R_FLOAT = /left|right|inline/, R_FLOAT = /left|right|inline/,
@ -91,6 +93,8 @@
savedInputChecked = [], savedInputChecked = [],
touchDragOverListeners = [], touchDragOverListeners = [],
alwaysFalse = function () { return false; },
_autoScroll = _throttle(function (/**Event*/evt, /**Object*/options, /**HTMLElement*/rootEl) { _autoScroll = _throttle(function (/**Event*/evt, /**Object*/options, /**HTMLElement*/rootEl) {
// Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521 // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
if (rootEl && options.scroll) { if (rootEl && options.scroll) {
@ -163,7 +167,9 @@
scrollOffsetX = vx ? vx * speed : 0; scrollOffsetX = vx ? vx * speed : 0;
if ('function' === typeof(scrollCustomFn)) { if ('function' === typeof(scrollCustomFn)) {
return scrollCustomFn.call(_this, scrollOffsetX, scrollOffsetY, evt); if (scrollCustomFn.call(_this, scrollOffsetX, scrollOffsetY, evt, touchEvt, el) !== 'continue') {
return;
}
} }
if (el === win) { if (el === win) {
@ -180,8 +186,11 @@
_prepareGroup = function (options) { _prepareGroup = function (options) {
function toFn(value, pull) { function toFn(value, pull) {
if (value === void 0 || value === true) { if (value == null || value === true) {
value = group.name; value = group.name;
if (value == null) {
return alwaysFalse;
}
} }
if (typeof value === 'function') { if (typeof value === 'function') {
@ -220,7 +229,9 @@
try { try {
window.addEventListener('test', null, Object.defineProperty({}, 'passive', { window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
get: function () { get: function () {
passiveMode = true; // `false`, because everything starts to work incorrectly and instead of d'n'd,
// begins the page has scrolled.
passiveMode = false;
captureMode = { captureMode = {
capture: false, capture: false,
passive: passiveMode passive: passiveMode
@ -248,7 +259,7 @@
// Default options // Default options
var defaults = { var defaults = {
group: Math.random(), group: null,
sort: true, sort: true,
disabled: false, disabled: false,
store: null, store: null,
@ -277,7 +288,7 @@
fallbackOnBody: false, fallbackOnBody: false,
fallbackTolerance: 0, fallbackTolerance: 0,
fallbackOffset: {x: 0, y: 0}, fallbackOffset: {x: 0, y: 0},
supportPointer: Sortable.supportPointer !== false, supportPointer: Sortable.supportPointer !== false
}; };
@ -551,7 +562,7 @@
var parent = target; var parent = target;
var i = touchDragOverListeners.length; var i = touchDragOverListeners.length;
if (target && target.shadowRoot) { while (target && target.shadowRoot) {
target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY); target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
parent = target; parent = target;
} }
@ -726,7 +737,7 @@
canSort = options.sort; canSort = options.sort;
if (evt.preventDefault !== void 0) { if (evt.preventDefault !== void 0) {
!passiveMode && evt.preventDefault(); evt.preventDefault();
!options.dragoverBubble && evt.stopPropagation(); !options.dragoverBubble && evt.stopPropagation();
} }
@ -888,7 +899,7 @@
+ (prevRect.top - currentRect.top) + 'px,0)' + (prevRect.top - currentRect.top) + 'px,0)'
); );
target.offsetWidth; // repaint forRepaintDummy = target.offsetWidth; // repaint
_css(target, 'transition', 'all ' + ms + 'ms'); _css(target, 'transition', 'all ' + ms + 'ms');
_css(target, 'transform', 'translate3d(0,0,0)'); _css(target, 'transform', 'translate3d(0,0,0)');
@ -939,7 +950,7 @@
if (evt) { if (evt) {
if (moved) { if (moved) {
!passiveMode && evt.preventDefault(); evt.preventDefault();
!options.dropBubble && evt.stopPropagation(); !options.dropBubble && evt.stopPropagation();
} }
@ -963,21 +974,21 @@
_toggleClass(dragEl, this.options.chosenClass, false); _toggleClass(dragEl, this.options.chosenClass, false);
// Drag stop event // Drag stop event
_dispatchEvent(this, rootEl, 'unchoose', dragEl, parentEl, rootEl, oldIndex); _dispatchEvent(this, rootEl, 'unchoose', dragEl, parentEl, rootEl, oldIndex, null, evt);
if (rootEl !== parentEl) { if (rootEl !== parentEl) {
newIndex = _index(dragEl, options.draggable); newIndex = _index(dragEl, options.draggable);
if (newIndex >= 0) { if (newIndex >= 0) {
// Add event // Add event
_dispatchEvent(null, parentEl, 'add', dragEl, parentEl, rootEl, oldIndex, newIndex); _dispatchEvent(null, parentEl, 'add', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
// Remove event // Remove event
_dispatchEvent(this, rootEl, 'remove', dragEl, parentEl, rootEl, oldIndex, newIndex); _dispatchEvent(this, rootEl, 'remove', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
// drag from one list and drop into another // drag from one list and drop into another
_dispatchEvent(null, parentEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex); _dispatchEvent(null, parentEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
_dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex); _dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
} }
} }
else { else {
@ -987,8 +998,8 @@
if (newIndex >= 0) { if (newIndex >= 0) {
// drag & drop within the same list // drag & drop within the same list
_dispatchEvent(this, rootEl, 'update', dragEl, parentEl, rootEl, oldIndex, newIndex); _dispatchEvent(this, rootEl, 'update', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
_dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex); _dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
} }
} }
} }
@ -999,7 +1010,7 @@
newIndex = oldIndex; newIndex = oldIndex;
} }
_dispatchEvent(this, rootEl, 'end', dragEl, parentEl, rootEl, oldIndex, newIndex); _dispatchEvent(this, rootEl, 'end', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
// Save sorting // Save sorting
this.save(); this.save();
@ -1238,7 +1249,7 @@
if (evt.dataTransfer) { if (evt.dataTransfer) {
evt.dataTransfer.dropEffect = 'move'; evt.dataTransfer.dropEffect = 'move';
} }
!passiveMode && evt.preventDefault(); evt.preventDefault();
} }
@ -1308,7 +1319,7 @@
function _dispatchEvent(sortable, rootEl, name, targetEl, toEl, fromEl, startIndex, newIndex) { function _dispatchEvent(sortable, rootEl, name, targetEl, toEl, fromEl, startIndex, newIndex, originalEvt) {
sortable = (sortable || rootEl[expando]); sortable = (sortable || rootEl[expando]);
var evt = document.createEvent('Event'), var evt = document.createEvent('Event'),
@ -1325,6 +1336,8 @@
evt.oldIndex = startIndex; evt.oldIndex = startIndex;
evt.newIndex = newIndex; evt.newIndex = newIndex;
evt.originalEvent = originalEvt;
rootEl.dispatchEvent(evt); rootEl.dispatchEvent(evt);
if (options[onName]) { if (options[onName]) {
@ -1350,6 +1363,8 @@
evt.relatedRect = targetRect || toEl.getBoundingClientRect(); evt.relatedRect = targetRect || toEl.getBoundingClientRect();
evt.willInsertAfter = willInsertAfter; evt.willInsertAfter = willInsertAfter;
evt.originalEvent = originalEvt;
fromEl.dispatchEvent(evt); fromEl.dispatchEvent(evt);
if (onMoveFn) { if (onMoveFn) {
@ -1425,15 +1440,15 @@
function _matches(/**HTMLElement*/el, /**String*/selector) { function _matches(/**HTMLElement*/el, /**String*/selector) {
if (el) { if (el) {
selector = selector.split('.'); try {
if (el.matches) {
var tag = selector.shift().toUpperCase(), return el.matches(selector);
re = new RegExp('\\s(' + selector.join('|') + ')(?=\\s)', 'g'); } else if (el.msMatchesSelector) {
return el.msMatchesSelector(selector);
return ( }
(tag === '' || el.nodeName.toUpperCase() == tag) && } catch(_) {
(!selector.length || ((' ' + el.className + ' ').match(re) || []).length == selector.length) return false;
); }
} }
return false; return false;
@ -1485,6 +1500,8 @@
} }
function _saveInputCheckedState(root) { function _saveInputCheckedState(root) {
savedInputChecked.length = 0;
var inputs = root.getElementsByTagName('input'); var inputs = root.getElementsByTagName('input');
var idx = inputs.length; var idx = inputs.length;
@ -1540,6 +1557,6 @@
// Export // Export
Sortable.version = '1.6.1'; Sortable.version = '1.7.0';
return Sortable; return Sortable;
}); });

4
Sortable.min.js vendored

File diff suppressed because one or more lines are too long

2
component.json

@ -1,7 +1,7 @@
{ {
"name": "Sortable", "name": "Sortable",
"main": "Sortable.js", "main": "Sortable.js",
"version": "1.6.1", "version": "1.7.0",
"homepage": "http://rubaxa.github.io/Sortable/", "homepage": "http://rubaxa.github.io/Sortable/",
"repo": "RubaXa/Sortable", "repo": "RubaXa/Sortable",
"authors": [ "authors": [

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "sortablejs", "name": "sortablejs",
"exportName": "Sortable", "exportName": "Sortable",
"version": "1.6.1", "version": "1.7.0",
"devDependencies": { "devDependencies": {
"grunt": "*", "grunt": "*",
"grunt-contrib-jshint": "*", "grunt-contrib-jshint": "*",

Loading…
Cancel
Save