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

Function index

Sortable.js:392–405  ·  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

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

Callers 9

dragStartGlobalFunction · 0.90
dropFunction · 0.90
eventPropertiesFunction · 0.90
swapNodesFunction · 0.90
Sortable.jsFile · 0.70
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…