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. 18
      README.md
  2. 77
      Sortable.js
  3. 4
      Sortable.min.js
  4. 2
      component.json
  5. 2
      package.json

18
README.md

@ -99,10 +99,10 @@ var sortable = new Sortable(el, {
fallbackClass: "sortable-fallback", // Class name for the cloned DOM Element when using forceFallback
fallbackOnBody: false, // Appends the cloned DOM Element into the Document's Body
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
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.
scrollSpeed: 10, // px
@ -164,7 +164,7 @@ var sortable = new Sortable(el, {
originalEvent.clientY; // mouse position
// return false; — for cancel
},
// Called when creating a clone of element
onClone: function (/**Event*/evt) {
var origEl = evt.item;
@ -362,7 +362,7 @@ Demo: http://jsbin.com/yacuqib/edit?html,css,js,output
Emulates the native drag threshold. Specify in pixels how far the mouse should move before it's considered as a drag.
Useful if the items are also clickable like in a list of links.
When the user clicks inside a sortable element, it's not uncommon for your hand to move a little between the time you press and the time you release.
When the user clicks inside a sortable element, it's not uncommon for your hand to move a little between the time you press and the time you release.
Dragging only starts if you move the pointer past a certain tolerance, so that you don't accidentally start dragging every time you click.
3 to 5 are probably good values.
@ -576,12 +576,12 @@ Link to the active instance.
### CDN
```html
<!-- jsDelivr :: Sortable (http://www.jsdelivr.com/package/npm/sortablejs) -->
<script src="//cdn.jsdelivr.net/npm/sortablejs@1.6.1/Sortable.min.js"></script>
<!-- jsDelivr :: Sortable (https://www.jsdelivr.com/package/npm/sortablejs) -->
<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) -->
<script src="//cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
<!-- jsDelivr :: Sortable :: Latest (https://www.jsdelivr.com/package/npm/sortablejs) -->
<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
```

77
Sortable.js

@ -55,6 +55,8 @@
moved,
forRepaintDummy,
/** @const */
R_SPACE = /\s+/g,
R_FLOAT = /left|right|inline/,
@ -91,6 +93,8 @@
savedInputChecked = [],
touchDragOverListeners = [],
alwaysFalse = function () { return false; },
_autoScroll = _throttle(function (/**Event*/evt, /**Object*/options, /**HTMLElement*/rootEl) {
// Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
if (rootEl && options.scroll) {
@ -163,7 +167,9 @@
scrollOffsetX = vx ? vx * speed : 0;
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) {
@ -180,8 +186,11 @@
_prepareGroup = function (options) {
function toFn(value, pull) {
if (value === void 0 || value === true) {
if (value == null || value === true) {
value = group.name;
if (value == null) {
return alwaysFalse;
}
}
if (typeof value === 'function') {
@ -220,7 +229,9 @@
try {
window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
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 = {
capture: false,
passive: passiveMode
@ -248,12 +259,12 @@
// Default options
var defaults = {
group: Math.random(),
group: null,
sort: true,
disabled: false,
store: null,
handle: null,
scroll: true,
scroll: true,
scrollSensitivity: 30,
scrollSpeed: 10,
draggable: /[uo]l/i.test(el.nodeName) ? 'li' : '>*',
@ -277,7 +288,7 @@
fallbackOnBody: false,
fallbackTolerance: 0,
fallbackOffset: {x: 0, y: 0},
supportPointer: Sortable.supportPointer !== false,
supportPointer: Sortable.supportPointer !== false
};
@ -551,7 +562,7 @@
var parent = target;
var i = touchDragOverListeners.length;
if (target && target.shadowRoot) {
while (target && target.shadowRoot) {
target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
parent = target;
}
@ -726,7 +737,7 @@
canSort = options.sort;
if (evt.preventDefault !== void 0) {
!passiveMode && evt.preventDefault();
evt.preventDefault();
!options.dragoverBubble && evt.stopPropagation();
}
@ -888,7 +899,7 @@
+ (prevRect.top - currentRect.top) + 'px,0)'
);
target.offsetWidth; // repaint
forRepaintDummy = target.offsetWidth; // repaint
_css(target, 'transition', 'all ' + ms + 'ms');
_css(target, 'transform', 'translate3d(0,0,0)');
@ -939,7 +950,7 @@
if (evt) {
if (moved) {
!passiveMode && evt.preventDefault();
evt.preventDefault();
!options.dropBubble && evt.stopPropagation();
}
@ -963,21 +974,21 @@
_toggleClass(dragEl, this.options.chosenClass, false);
// Drag stop event
_dispatchEvent(this, rootEl, 'unchoose', dragEl, parentEl, rootEl, oldIndex);
_dispatchEvent(this, rootEl, 'unchoose', dragEl, parentEl, rootEl, oldIndex, null, evt);
if (rootEl !== parentEl) {
newIndex = _index(dragEl, options.draggable);
if (newIndex >= 0) {
// Add event
_dispatchEvent(null, parentEl, 'add', dragEl, parentEl, rootEl, oldIndex, newIndex);
_dispatchEvent(null, parentEl, 'add', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
// 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
_dispatchEvent(null, parentEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, '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, evt);
}
}
else {
@ -987,8 +998,8 @@
if (newIndex >= 0) {
// drag & drop within the same list
_dispatchEvent(this, rootEl, 'update', dragEl, parentEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, 'update', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
_dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
}
}
}
@ -999,7 +1010,7 @@
newIndex = oldIndex;
}
_dispatchEvent(this, rootEl, 'end', dragEl, parentEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, 'end', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
// Save sorting
this.save();
@ -1238,7 +1249,7 @@
if (evt.dataTransfer) {
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]);
var evt = document.createEvent('Event'),
@ -1325,6 +1336,8 @@
evt.oldIndex = startIndex;
evt.newIndex = newIndex;
evt.originalEvent = originalEvt;
rootEl.dispatchEvent(evt);
if (options[onName]) {
@ -1350,6 +1363,8 @@
evt.relatedRect = targetRect || toEl.getBoundingClientRect();
evt.willInsertAfter = willInsertAfter;
evt.originalEvent = originalEvt;
fromEl.dispatchEvent(evt);
if (onMoveFn) {
@ -1425,15 +1440,15 @@
function _matches(/**HTMLElement*/el, /**String*/selector) {
if (el) {
selector = selector.split('.');
var tag = selector.shift().toUpperCase(),
re = new RegExp('\\s(' + selector.join('|') + ')(?=\\s)', 'g');
return (
(tag === '' || el.nodeName.toUpperCase() == tag) &&
(!selector.length || ((' ' + el.className + ' ').match(re) || []).length == selector.length)
);
try {
if (el.matches) {
return el.matches(selector);
} else if (el.msMatchesSelector) {
return el.msMatchesSelector(selector);
}
} catch(_) {
return false;
}
}
return false;
@ -1485,6 +1500,8 @@
}
function _saveInputCheckedState(root) {
savedInputChecked.length = 0;
var inputs = root.getElementsByTagName('input');
var idx = inputs.length;
@ -1540,6 +1557,6 @@
// Export
Sortable.version = '1.6.1';
Sortable.version = '1.7.0';
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",
"main": "Sortable.js",
"version": "1.6.1",
"version": "1.7.0",
"homepage": "http://rubaxa.github.io/Sortable/",
"repo": "RubaXa/Sortable",
"authors": [

2
package.json

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

Loading…
Cancel
Save