Fix hit testing threshold (#969)

* Fix hit testing threshold

- The bounding box was not correctly extended to take into account the threshold. It was only for y axis but not x.
- The bezier threshold was using 20 instead of 10 and not taking into account zoom level.

Both those issues are fixed and now the behavior looks good on all the shapes I can test.

* fix_tests
This commit is contained in:
Christopher Chedeau
2020-03-15 13:42:18 -07:00
committed by GitHub
parent 2937efacde
commit fed7054114
2 changed files with 56 additions and 11 deletions

View File

@ -163,10 +163,23 @@ describe("select single element on the scene", () => {
fireEvent.keyDown(document, { key: KEYS.ESCAPE });
}
/*
1 2 3 4 5 6 7 8 9
1
2 x
3
4 .
5
6
7 x
8
9
*/
const tool = getByToolName("selection");
fireEvent.click(tool);
// click on a line on the rectangle
fireEvent.pointerDown(canvas, { clientX: 45, clientY: 20 });
// click on a line on the arrow
fireEvent.pointerDown(canvas, { clientX: 40, clientY: 40 });
fireEvent.pointerUp(canvas);
expect(renderScene).toHaveBeenCalledTimes(7);
@ -175,7 +188,7 @@ describe("select single element on the scene", () => {
expect(h.appState.selectedElementIds[h.elements[0].id]).toBeTruthy();
});
it("arrow", () => {
it("arrow escape", () => {
const { getByToolName, container } = render(<App />);
const canvas = container.querySelector("canvas")!;
{
@ -188,10 +201,23 @@ describe("select single element on the scene", () => {
fireEvent.keyDown(document, { key: KEYS.ESCAPE });
}
/*
1 2 3 4 5 6 7 8 9
1
2 x
3
4 .
5
6
7 x
8
9
*/
const tool = getByToolName("selection");
fireEvent.click(tool);
// click on a line on the rectangle
fireEvent.pointerDown(canvas, { clientX: 45, clientY: 20 });
// click on a line on the arrow
fireEvent.pointerDown(canvas, { clientX: 40, clientY: 40 });
fireEvent.pointerUp(canvas);
expect(renderScene).toHaveBeenCalledTimes(7);