MCPcopy Index your code
hub / github.com/SortableJS/Sortable / Sortable

Function Sortable

src/Sortable.js:349–446  ·  view source on GitHub ↗

* @class Sortable * @param {HTMLElement} el * @param {Object} [options]

(el, options)

Source from the content-addressed store, hash-verified

347 * @param {Object} [options]
348 */
349function Sortable(el, options) {
350 if (!(el && el.nodeType && el.nodeType === 1)) {
351 throw `Sortable: \`el\` must be an HTMLElement, not ${ {}.toString.call(el) }`;
352 }
353
354 this.el = el; // root element
355 this.options = options = Object.assign({}, options);
356
357
358 // Export instance
359 el[expando] = this;
360
361 let defaults = {
362 group: null,
363 sort: true,
364 disabled: false,
365 store: null,
366 handle: null,
367 draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
368 swapThreshold: 1, // percentage; 0 <= x <= 1
369 invertSwap: false, // invert always
370 invertedSwapThreshold: null, // will be set to same as swapThreshold if default
371 removeCloneOnHide: true,
372 direction: function() {
373 return _detectDirection(el, this.options);
374 },
375 ghostClass: 'sortable-ghost',
376 chosenClass: 'sortable-chosen',
377 dragClass: 'sortable-drag',
378 ignore: 'a, img',
379 filter: null,
380 preventOnFilter: true,
381 animation: 0,
382 easing: null,
383 setData: function (dataTransfer, dragEl) {
384 dataTransfer.setData('Text', dragEl.textContent);
385 },
386 dropBubble: false,
387 dragoverBubble: false,
388 dataIdAttr: 'data-id',
389 delay: 0,
390 delayOnTouchOnly: false,
391 touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
392 forceFallback: false,
393 fallbackClass: 'sortable-fallback',
394 fallbackOnBody: false,
395 fallbackTolerance: 0,
396 fallbackOffset: {x: 0, y: 0},
397 // Disabled on Safari: #1571; Enabled on Safari IOS: #2244
398 supportPointer: Sortable.supportPointer !== false && ('PointerEvent' in window) && (!Safari || IOS),
399 emptyInsertThreshold: 5
400 };
401
402 PluginManager.initializePlugins(this, el, defaults);
403
404 // Set default options
405 for (let name in defaults) {
406 !(name in options) && (options[name] = defaults[name]);

Callers

nothing calls this directly

Calls 4

onFunction · 0.90
_detectDirectionFunction · 0.70
_prepareGroupFunction · 0.70
AnimationStateManagerFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…