Skip to content

Commit 8e9117e

Browse files
committed
Update drop edge tolerance to feel smoother
1 parent 0bda0c0 commit 8e9117e

2 files changed

Lines changed: 34 additions & 34 deletions

File tree

src/core/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ export const DEFAULT_PHYSICS: Physics = Object.freeze({
110110
SHOULD_ROUND: false,
111111
OVERLAY_CLASSNAME: "overlay",
112112
MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD: 0.15,
113-
SPLIT_EDGE_TOLERANCE: 0.25,
114-
SPLIT_ROOT_EDGE_TOLERANCE: 0.01,
113+
SPLIT_EDGE_TOLERANCE: 0.33,
114+
SPLIT_ROOT_EDGE_TOLERANCE: 0.1,
115115
GRID_TRACK_COLLAPSE_TOLERANCE: 0.001,
116116
OVERLAY_DEFAULT: "absolute",
117117
GRID_DIVIDER_SIZE: 6,

tests/unit/calculate_edge.spec.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import { expect, test } from "@playwright/test";
1313
import { LAYOUTS } from "../helpers/fixtures.ts";
1414
import { calculate_edge } from "../../src/layout/calculate_edge.ts";
1515
import { calculate_intersection } from "../../src/layout/calculate_intersect.ts";
16-
import type { Layout, LayoutPath } from "../../src/layout/types.ts";
16+
import type { Layout, LayoutPath } from "../../src/core/types.ts";
1717

1818
test("cursor in center of panel - no split", () => {
19-
const drop_target = calculate_intersection(0.3, 0.5, LAYOUTS.NESTED_BASIC);
19+
const drop_target = calculate_intersection(0.3, 0.65, LAYOUTS.NESTED_BASIC);
2020
expect(drop_target).not.toBeNull();
2121
const result = calculate_edge(
2222
0.3,
23-
0.5,
23+
0.65,
2424
LAYOUTS.NESTED_BASIC,
2525
"DDD",
2626
// biome-ignore lint/style/noNonNullAssertion: playwright assertion
@@ -68,10 +68,10 @@ test("cursor near right edge of vertical split panel", () => {
6868
});
6969

7070
test("cursor near top edge of horizontal split panel", () => {
71-
const drop_target = calculate_intersection(0.7, 0.05, LAYOUTS.NESTED_BASIC);
71+
const drop_target = calculate_intersection(0.75, 0.12, LAYOUTS.NESTED_BASIC);
7272
const result = calculate_edge(
73-
0.7,
74-
0.05,
73+
0.75,
74+
0.12,
7575
LAYOUTS.NESTED_BASIC,
7676
"DDD",
7777
// biome-ignore lint/style/noNonNullAssertion: playwright assertion
@@ -85,10 +85,10 @@ test("cursor near top edge of horizontal split panel", () => {
8585
});
8686

8787
test("cursor near bottom edge of horizontal split panel", () => {
88-
const drop_target = calculate_intersection(0.7, 0.95, LAYOUTS.NESTED_BASIC);
88+
const drop_target = calculate_intersection(0.75, 0.88, LAYOUTS.NESTED_BASIC);
8989
const result = calculate_edge(
90-
0.7,
91-
0.95,
90+
0.75,
91+
0.88,
9292
LAYOUTS.NESTED_BASIC,
9393
"DDD",
9494
// biome-ignore lint/style/noNonNullAssertion: playwright assertion
@@ -313,24 +313,24 @@ test("cursor in bottom-right corner prioritizes row offset", () => {
313313
layout: undefined as unknown as Layout,
314314
path: [],
315315
view_window: { row_start: 0, row_end: 1, col_start: 0, col_end: 1 },
316-
column: 0.9,
317-
row: 0.95,
318-
column_offset: 0.9,
319-
row_offset: 0.95,
316+
column: 0.85,
317+
row: 0.89,
318+
column_offset: 0.85,
319+
row_offset: 0.89,
320320
orientation: "horizontal",
321321
is_edge: false,
322322
};
323323

324-
const result = calculate_edge(0.9, 0.95, singlePanel, "BBB", drop_target);
324+
const result = calculate_edge(0.85, 0.89, singlePanel, "BBB", drop_target);
325325
expect(result).toStrictEqual({
326-
column: 0.9,
327-
column_offset: 0.9,
326+
column: 0.85,
327+
column_offset: 0.85,
328328
is_edge: true,
329329
layout: undefined,
330330
orientation: "vertical",
331331
path: [1],
332-
row: 0.95,
333-
row_offset: 0.95,
332+
row: 0.89,
333+
row_offset: 0.89,
334334
slot: "AAA",
335335
type: "layout-path",
336336
view_window: {
@@ -350,24 +350,24 @@ test("cursor in bottom-right corner prioritizes column offset", () => {
350350
layout: undefined as unknown as Layout,
351351
path: [],
352352
view_window: { row_start: 0, row_end: 1, col_start: 0, col_end: 1 },
353-
column: 0.95,
354-
row: 0.9,
355-
column_offset: 0.95,
356-
row_offset: 0.9,
353+
column: 0.89,
354+
row: 0.85,
355+
column_offset: 0.89,
356+
row_offset: 0.85,
357357
orientation: "horizontal",
358358
is_edge: false,
359359
};
360360

361-
const result = calculate_edge(0.95, 0.9, singlePanel, "BBB", drop_target);
361+
const result = calculate_edge(0.89, 0.85, singlePanel, "BBB", drop_target);
362362
expect(result).toStrictEqual({
363-
column: 0.95,
364-
column_offset: 0.95,
363+
column: 0.89,
364+
column_offset: 0.89,
365365
is_edge: true,
366366
layout: undefined,
367367
orientation: "horizontal",
368368
path: [1],
369-
row: 0.9,
370-
row_offset: 0.9,
369+
row: 0.85,
370+
row_offset: 0.85,
371371
slot: "AAA",
372372
type: "layout-path",
373373
view_window: {
@@ -387,15 +387,15 @@ test("cursor near edge with offset exactly at tolerance threshold", () => {
387387
path: [],
388388
layout: undefined as unknown as Layout,
389389
view_window: { row_start: 0, row_end: 1, col_start: 0, col_end: 1 },
390-
column: 0.3,
390+
column: 0.35,
391391
row: 0.5,
392-
column_offset: 0.3,
392+
column_offset: 0.35,
393393
row_offset: 0.5,
394394
orientation: "horizontal",
395395
is_edge: false,
396396
};
397397

398-
const result = calculate_edge(0.3, 0.5, singlePanel, "BBB", drop_target);
398+
const result = calculate_edge(0.35, 0.65, singlePanel, "BBB", drop_target);
399399
expect(result.is_edge).toBe(false);
400400
expect(result.path).toStrictEqual([0]);
401401
});
@@ -421,9 +421,9 @@ test("cursor near edge with offset just below tolerance threshold", () => {
421421
});
422422

423423
test("nested panel with vertical orientation at left edge", () => {
424-
const drop_target = calculate_intersection(0.02, 0.5, LAYOUTS.NESTED_BASIC);
424+
const drop_target = calculate_intersection(0.12, 0.5, LAYOUTS.NESTED_BASIC);
425425
const result = calculate_edge(
426-
0.02,
426+
0.12,
427427
0.5,
428428
LAYOUTS.NESTED_BASIC,
429429
"DDD",

0 commit comments

Comments
 (0)