Fixed bug where target mode would contain parents of hit nodes
Summary: The idea of the hit test is to return the deepest children that hit an element and not their parents. Due to this bug we were actually returning every other node all the way up to the root resulting in way to many hit nodes for target mode Reviewed By: lblasa Differential Revision: D47949837 fbshipit-source-id: d3391b4a700ab0be4c3b21dde5f13452f90c887b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fb503a0a2f
commit
129c848b78
@@ -530,18 +530,19 @@ function hitTest(node: NestedNode, mouseCoordinate: Coordinate): NestedNode[] {
|
||||
children = [node.children[node.activeChildIdx]];
|
||||
}
|
||||
const offsetMouseCoord = offsetCoordinate(mouseCoordinate, nodeBounds);
|
||||
let childHit = false;
|
||||
let anyChildHitRecursive = false;
|
||||
|
||||
for (const child of children) {
|
||||
childHit = hitTestRec(child, offsetMouseCoord) || childHit;
|
||||
anyChildHitRecursive =
|
||||
hitTestRec(child, offsetMouseCoord) || anyChildHitRecursive;
|
||||
}
|
||||
|
||||
const hit = thisNodeHit && !childHit;
|
||||
const hit = thisNodeHit && !anyChildHitRecursive;
|
||||
if (hit) {
|
||||
res.push(node);
|
||||
}
|
||||
|
||||
return hit;
|
||||
return thisNodeHit || anyChildHitRecursive;
|
||||
}
|
||||
|
||||
hitTestRec(node, mouseCoordinate);
|
||||
|
||||
Reference in New Issue
Block a user