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

Function _detectDirection

Sortable.js:925–945  ·  view source on GitHub ↗
(el, options)

Source from the content-addressed store, hash-verified

923 return el.style.pointerEvents === 'auto';
924 }(),
925 _detectDirection = function _detectDirection(el, options) {
926 var elCSS = css(el),
927 elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
928 child1 = getChild(el, 0, options),
929 child2 = getChild(el, 1, options),
930 firstChildCSS = child1 && css(child1),
931 secondChildCSS = child2 && css(child2),
932 firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
933 secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
934 if (elCSS.display === 'flex') {
935 return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
936 }
937 if (elCSS.display === 'grid') {
938 return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
939 }
940 if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
941 var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
942 return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
943 }
944 return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
945 },
946 _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
947 var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
948 dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,

Callers 1

SortableFunction · 0.70

Calls 3

cssFunction · 0.70
getChildFunction · 0.70
getRectFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…