Virtual whiteboard for sketching hand-drawn like diagrams
Fix hit testing (#119)
Christopher Chedeau25aabdc4d1d2
diff --git a/src/index.tsx b/src/index.tsxindex 34fd7edb1f..1cf1baa3b9 100644--- a/src/index.tsx+++ b/src/index.tsx@@ -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 somethingif (hitElement) {