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

Function getChild

src/utils.js:319–340  ·  view source on GitHub ↗

* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible) * and non-draggable elements * @param {HTMLElement} el The parent element * @param {Number} childNum The index of the child * @param {Object} options Parent Sortable'

(el, childNum, options, includeDragEl)

Source from the content-addressed store, hash-verified

317 * @return {HTMLElement} The child at index childNum, or null if not found
318 */
319function getChild(el, childNum, options, includeDragEl) {
320 let currentChild = 0,
321 i = 0,
322 children = el.children;
323
324 while (i < children.length) {
325 if (
326 children[i].style.display !== 'none' &&
327 children[i] !== Sortable.ghost &&
328 (includeDragEl || children[i] !== Sortable.dragged) &&
329 closest(children[i], options.draggable, el, false)
330 ) {
331 if (currentChild === childNum) {
332 return children[i];
333 }
334 currentChild++;
335 }
336
337 i++;
338 }
339 return null;
340}
341
342/**
343 * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)

Callers 3

_detectDirectionFunction · 0.90
Sortable.jsFile · 0.90
_ghostIsFirstFunction · 0.90

Calls 1

closestFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…