stash
This commit is contained in:
parent
046b23c225
commit
2fdcc19933
1 changed files with 7 additions and 7 deletions
|
@ -42,23 +42,23 @@ export default {
|
||||||
calculateOffset(container, node, offset) {
|
calculateOffset(container, node, offset) {
|
||||||
let position = 0;
|
let position = 0;
|
||||||
let found = false;
|
let found = false;
|
||||||
const walk = (node) => {
|
const walk = (elem) => {
|
||||||
if (node === container) {
|
if (elem === node) {
|
||||||
found = true;
|
found = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (node.nodeType === 3) {
|
if (elem.nodeType === 3) {
|
||||||
position += node.length;
|
position += elem.length;
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < node.childNodes.length; i++) {
|
for (let i = 0; i < elem.childNodes.length; i++) {
|
||||||
walk(node.childNodes[i]);
|
walk(elem.childNodes[i]);
|
||||||
if (found) {
|
if (found) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
walk(node);
|
walk(container);
|
||||||
return position + offset;
|
return position + offset;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue