Fix hit testing (#119)

This commit is contained in:
Christopher Chedeau 2020-01-04 10:19:18 -08:00 committed by GitHub
parent dcf252f03c
commit 25aabdc4d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1021,9 +1021,14 @@ class App extends React.Component<{}, AppState> {
let isDraggingElements = false;
const cursorStyle = document.documentElement.style.cursor;
if (this.state.elementType === "selection") {
const hitElement = elements.find(element => {
return hitTest(element, x, y);
});
let hitElement = null;
// We need to to hit testing from front (end of the array) to back (beginning of the array)
for (let i = elements.length - 1; i >= 0; --i) {
if (hitTest(elements[i], x, y)) {
hitElement = elements[i];
break;
}
}
// If we click on something
if (hitElement) {