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

Function index

modular/sortable.complete.esm.js:386–399  ·  view source on GitHub ↗

* Returns the index of an element within its parent for a selected set of * elements * @param {HTMLElement} el * @param {selector} selector * @return {number}

(el, selector)

Source from the content-addressed store, hash-verified

384 * @return {number}
385 */
386function index(el, selector) {
387 var index = 0;
388 if (!el || !el.parentNode) {
389 return -1;
390 }
391
392 /* jshint boss:true */
393 while (el = el.previousElementSibling) {
394 if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
395 index++;
396 }
397 }
398 return index;
399}
400
401/**
402 * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.

Callers 5

changedFunction · 0.70
_getInsertDirectionFunction · 0.70
swapNodesFunction · 0.70
MultiDragPluginFunction · 0.70

Calls 1

matchesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…