refactor: any UI child node

This commit is contained in:
cha0s 2019-04-18 21:39:09 -05:00
parent fdd176644a
commit ccddb4e465

View File

@ -128,14 +128,24 @@ let pointingAt = [-1, -1];
function isPointingAtAnything() {
return -1 !== pointingAt[0] && -1 !== pointingAt[1];
}
function isInUi(node) {
let walk = node;
while (walk) {
if (walk === stage.ui) {
return true;
}
walk = walk.parentNode;
}
return false;
}
stage.on('pointerDown', (event) => {
if (event.target !== stage.ui) {
if (!isInUi(event.target)) {
return;
}
pointingAt = event.position;
});
stage.on('pointerMove', (event) => {
if (event.target !== stage.ui) {
if (!isInUi(event.target)) {
return;
}
if (!isPointingAtAnything()) {