const allChildren = getAllChildren(array);
const textChildren = getTextChildren(allChildren);
const arr = getResultArr(textChildren);
function getAllChildren(array) {
const allChildren = [];
for (const {key, value} of array) {
if (key.value !== 'content')
continue;
allChildren.push(...value.children);
}
return allChildren;
}
function getTextChildren(allChildren) {
const textChildren = [];
for (const text of allChildren) {
textChildren.push(...text.children);
}
return textChildren;
}
function getResultArr(textChildren) {
const arr = []
for (const {key, value} of textChildren) {
if (key.value !== 'mods')
continue;
const [first] = value.children;
const {key, value, loc} = first;
if (key.value !== 'size')
continue;
arr.push({
loc,
value: value.value,
});
}
return arr;
}
const getRect = (el) => el.tooltip.element.getBoundingClientRect();
function isThumbsCollision({from, to, settings}) {
const fromRect = getRect(from);
const {top, right, height, width} = getRect(to);
if (settings.isVertical)
return top - fromRect.top <= height;
return right - fromRect.right <= width
}