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

Function index

src/utils.js:373–388  ·  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

371 * @return {number}
372 */
373function index(el, selector) {
374 let index = 0;
375
376 if (!el || !el.parentNode) {
377 return -1;
378 }
379
380 /* jshint boss:true */
381 while (el = el.previousElementSibling) {
382 if ((el.nodeName.toUpperCase() !== 'TEMPLATE') && el !== Sortable.clone && (!selector || matches(el, selector))) {
383 index++;
384 }
385 }
386
387 return index;
388}
389
390/**
391 * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.

Callers 3

Sortable.jsFile · 0.90
changedFunction · 0.90
_getInsertDirectionFunction · 0.90

Calls 1

matchesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…