regular-layout 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -6
- package/dist/index.js.map +3 -3
- package/dist/layout/calculate_edge.d.ts +2 -1
- package/dist/layout/calculate_intersect.d.ts +8 -2
- package/dist/layout/constants.d.ts +76 -38
- package/dist/layout/generate_grid.d.ts +2 -1
- package/dist/layout/generate_overlay.d.ts +1 -1
- package/dist/layout/redistribute_panel_sizes.d.ts +1 -1
- package/dist/regular-layout.d.ts +14 -0
- package/package.json +1 -1
- package/src/layout/calculate_edge.ts +23 -15
- package/src/layout/calculate_intersect.ts +9 -7
- package/src/layout/constants.ts +94 -38
- package/src/layout/generate_grid.ts +68 -24
- package/src/layout/generate_overlay.ts +4 -2
- package/src/layout/redistribute_panel_sizes.ts +10 -3
- package/src/layout/types.ts +1 -0
- package/src/regular-layout-frame.ts +8 -5
- package/src/regular-layout.ts +96 -33
- package/themes/lorax.css +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Physics } from "./constants";
|
|
1
2
|
import type { Layout, LayoutPath } from "./types";
|
|
2
3
|
/**
|
|
3
4
|
* Calculates an insertion point (which may involve splitting a single
|
|
@@ -12,4 +13,4 @@ import type { Layout, LayoutPath } from "./types";
|
|
|
12
13
|
* @returns A new `LayoutPath` reflecting the updated (maybe) `"split-panel"`,
|
|
13
14
|
* which is enough to draw the overlay.
|
|
14
15
|
*/
|
|
15
|
-
export declare function calculate_edge(col: number, row: number, panel: Layout, slot: string, drop_target: LayoutPath, box?: DOMRect): LayoutPath;
|
|
16
|
+
export declare function calculate_edge(col: number, row: number, panel: Layout, slot: string, drop_target: LayoutPath, box?: DOMRect, physics?: Physics): LayoutPath;
|
|
@@ -12,5 +12,11 @@ import type { LayoutPath, LayoutDivider, Layout } from "./types.ts";
|
|
|
12
12
|
* boundary, or null if outside all panels
|
|
13
13
|
*/
|
|
14
14
|
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers?: null): LayoutPath | null;
|
|
15
|
-
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers?:
|
|
16
|
-
|
|
15
|
+
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers?: {
|
|
16
|
+
rect: DOMRect;
|
|
17
|
+
size: number;
|
|
18
|
+
}): LayoutPath | null | LayoutDivider;
|
|
19
|
+
export declare function calculate_intersection(column: number, row: number, layout: Layout, check_dividers?: {
|
|
20
|
+
rect: DOMRect;
|
|
21
|
+
size: number;
|
|
22
|
+
} | null): LayoutPath | null | LayoutDivider;
|
|
@@ -1,43 +1,81 @@
|
|
|
1
1
|
import type { OverlayMode } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Instance-specific constants which define the behavior and rendering details
|
|
4
|
+
* of a `<regular-layout>`.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export interface Physics {
|
|
7
|
+
/**
|
|
8
|
+
* The prefix to use for `CustomEvent`s generated by `regular-layout`, e.g.
|
|
9
|
+
* `"regular-layout-before-update"`.
|
|
10
|
+
*/
|
|
11
|
+
CUSTOM_EVENT_NAME_PREFIX: string;
|
|
12
|
+
/**
|
|
13
|
+
* The attribute name to use for matching child `Element`s to grid
|
|
14
|
+
* positions.
|
|
15
|
+
*/
|
|
16
|
+
CHILD_ATTRIBUTE_NAME: string;
|
|
17
|
+
/**
|
|
18
|
+
* The minimum number of pixels the mouse must move to be considered a drag.
|
|
19
|
+
*/
|
|
20
|
+
MIN_DRAG_DISTANCE: number;
|
|
21
|
+
/**
|
|
22
|
+
* Should floating point pixel calculations be rounded. Useful for testing.
|
|
23
|
+
*/
|
|
24
|
+
SHOULD_ROUND: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Class name to use for child elements in overlay position (dragging).
|
|
27
|
+
*/
|
|
28
|
+
OVERLAY_CLASSNAME: string;
|
|
29
|
+
/**
|
|
30
|
+
* The percentage of the maximum resize distance that will be clamped.
|
|
31
|
+
*/
|
|
32
|
+
MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD: number;
|
|
33
|
+
/**
|
|
34
|
+
* Threshold from panel edge that is considered a split vs drop action.
|
|
35
|
+
*/
|
|
36
|
+
SPLIT_EDGE_TOLERANCE: number;
|
|
37
|
+
/**
|
|
38
|
+
* Threshold from _container_ edge that is considered a split action on the root
|
|
39
|
+
* node.
|
|
40
|
+
*/
|
|
41
|
+
SPLIT_ROOT_EDGE_TOLERANCE: number;
|
|
42
|
+
/**
|
|
43
|
+
* Tolerance threshold for considering two grid track positions as identical.
|
|
44
|
+
*
|
|
45
|
+
* When collecting and deduplicating track positions, any positions closer than
|
|
46
|
+
* this value are treated as the same position to avoid redundant grid tracks.
|
|
47
|
+
*/
|
|
48
|
+
GRID_TRACK_COLLAPSE_TOLERANCE: number;
|
|
49
|
+
/**
|
|
50
|
+
* The overlay default behavior.
|
|
51
|
+
*/
|
|
52
|
+
OVERLAY_DEFAULT: OverlayMode;
|
|
53
|
+
/**
|
|
54
|
+
* Width of split panel dividers in pixels (for hit-test purposes).
|
|
55
|
+
*/
|
|
56
|
+
GRID_DIVIDER_SIZE: number;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the grid should trigger column resize if the grid itself is not
|
|
59
|
+
* the `event.target`.
|
|
60
|
+
*/
|
|
61
|
+
GRID_DIVIDER_CHECK_TARGET: boolean;
|
|
62
|
+
}
|
|
7
63
|
/**
|
|
8
|
-
*
|
|
64
|
+
* Like `GlobalPhysics`, but suitable for partial definition for incremental
|
|
65
|
+
* updates.
|
|
9
66
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* Threshold from _container_ edge that is considered a split action on the root
|
|
26
|
-
* node.
|
|
27
|
-
*/
|
|
28
|
-
export declare const SPLIT_ROOT_EDGE_TOLERANCE = 0.01;
|
|
29
|
-
/**
|
|
30
|
-
* Tolerance threshold for considering two grid track positions as identical.
|
|
31
|
-
*
|
|
32
|
-
* When collecting and deduplicating track positions, any positions closer than
|
|
33
|
-
* this value are treated as the same position to avoid redundant grid tracks.
|
|
34
|
-
*/
|
|
35
|
-
export declare const GRID_TRACK_COLLAPSE_TOLERANCE = 0.001;
|
|
36
|
-
/**
|
|
37
|
-
* The overlay default behavior.
|
|
38
|
-
*/
|
|
39
|
-
export declare const OVERLAY_DEFAULT: OverlayMode;
|
|
40
|
-
/**
|
|
41
|
-
* Width of split panel dividers in pixels (for hit-test purposes).
|
|
42
|
-
*/
|
|
43
|
-
export declare const GRID_DIVIDER_SIZE = 6;
|
|
67
|
+
export interface PhysicsUpdate {
|
|
68
|
+
CUSTOM_EVENT_NAME_PREFIX?: string;
|
|
69
|
+
CHILD_ATTRIBUTE_NAME?: string;
|
|
70
|
+
MIN_DRAG_DISTANCE?: number;
|
|
71
|
+
SHOULD_ROUND?: boolean;
|
|
72
|
+
OVERLAY_CLASSNAME?: string;
|
|
73
|
+
MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD?: number;
|
|
74
|
+
SPLIT_EDGE_TOLERANCE?: number;
|
|
75
|
+
SPLIT_ROOT_EDGE_TOLERANCE?: number;
|
|
76
|
+
GRID_TRACK_COLLAPSE_TOLERANCE?: number;
|
|
77
|
+
OVERLAY_DEFAULT?: OverlayMode;
|
|
78
|
+
GRID_DIVIDER_SIZE?: number;
|
|
79
|
+
GRID_DIVIDER_CHECK_TARGET?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export declare const DEFAULT_PHYSICS: Physics;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Physics } from "./constants.ts";
|
|
1
2
|
import type { Layout } from "./types.ts";
|
|
2
3
|
/**
|
|
3
4
|
* Generates CSS Grid styles to render a layout tree.
|
|
@@ -29,4 +30,4 @@ import type { Layout } from "./types.ts";
|
|
|
29
30
|
* // :host ::slotted([name=main]) { grid-column: 2; grid-row: 1; }
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
export declare function create_css_grid_layout(layout: Layout,
|
|
33
|
+
export declare function create_css_grid_layout(layout: Layout, overlay?: [string, string], physics?: Physics): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { LayoutPath } from "./types";
|
|
2
|
-
export declare function updateOverlaySheet(slot: string, box: DOMRect, style: CSSStyleDeclaration, drag_target: LayoutPath<undefined> | null): string;
|
|
2
|
+
export declare function updateOverlaySheet(slot: string, box: DOMRect, style: CSSStyleDeclaration, drag_target: LayoutPath<undefined> | null, physics?: import("./constants").Physics): string;
|
|
@@ -16,4 +16,4 @@ import type { Layout } from "./types.ts";
|
|
|
16
16
|
* @returns A new layout tree with updated sizes (original is not mutated).
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare function redistribute_panel_sizes(panel: Layout, path: number[], delta: number): Layout;
|
|
19
|
+
export declare function redistribute_panel_sizes(panel: Layout, path: number[], delta: number, physics?: import("./constants.ts").Physics): Layout;
|
package/dist/regular-layout.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LayoutPath, Layout, TabLayout, OverlayMode, Orientation } from "./layout/types.ts";
|
|
2
|
+
import { type PhysicsUpdate, type Physics } from "./layout/constants.ts";
|
|
2
3
|
/**
|
|
3
4
|
* A Web Component that provides a resizable panel layout system.
|
|
4
5
|
* Panels are arranged using CSS Grid and can be resized by dragging dividers.
|
|
@@ -40,6 +41,7 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
40
41
|
private _drag_target?;
|
|
41
42
|
private _cursor_override;
|
|
42
43
|
private _dimensions?;
|
|
44
|
+
private _physics;
|
|
43
45
|
constructor();
|
|
44
46
|
connectedCallback(): void;
|
|
45
47
|
disconnectedCallback(): void;
|
|
@@ -135,6 +137,18 @@ export declare class RegularLayout extends HTMLElement {
|
|
|
135
137
|
* ```
|
|
136
138
|
*/
|
|
137
139
|
save: () => Layout;
|
|
140
|
+
/**
|
|
141
|
+
* Override this instance's global constants.
|
|
142
|
+
*
|
|
143
|
+
* @param physics
|
|
144
|
+
*/
|
|
145
|
+
restorePhysics(physics: PhysicsUpdate): void;
|
|
146
|
+
/**
|
|
147
|
+
* Get this instance's constants.
|
|
148
|
+
*
|
|
149
|
+
* @returns The current constants
|
|
150
|
+
*/
|
|
151
|
+
savePhysics(): Physics;
|
|
138
152
|
/**
|
|
139
153
|
* Converts screen coordinates to relative layout coordinates.
|
|
140
154
|
*
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// ┃ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * ┃
|
|
10
10
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { DEFAULT_PHYSICS, type Physics } from "./constants";
|
|
13
13
|
import { insert_child } from "./insert_child";
|
|
14
14
|
import type { Layout, LayoutPath, Orientation, ViewWindow } from "./types";
|
|
15
15
|
|
|
@@ -33,39 +33,47 @@ export function calculate_edge(
|
|
|
33
33
|
slot: string,
|
|
34
34
|
drop_target: LayoutPath,
|
|
35
35
|
box?: DOMRect,
|
|
36
|
+
physics: Physics = DEFAULT_PHYSICS,
|
|
36
37
|
): LayoutPath {
|
|
37
38
|
// Check root edges first
|
|
38
|
-
if (col < SPLIT_ROOT_EDGE_TOLERANCE) {
|
|
39
|
+
if (col < physics.SPLIT_ROOT_EDGE_TOLERANCE) {
|
|
39
40
|
return insert_root_edge(panel, slot, drop_target, [0], true, "horizontal");
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
if (col > 1 - SPLIT_ROOT_EDGE_TOLERANCE) {
|
|
43
|
+
if (col > 1 - physics.SPLIT_ROOT_EDGE_TOLERANCE) {
|
|
43
44
|
return insert_root_edge(
|
|
44
45
|
panel,
|
|
45
46
|
slot,
|
|
46
47
|
drop_target,
|
|
47
|
-
drop_target.path.length > 0 ? drop_target.path : [],
|
|
48
|
+
drop_target.path.length > 0 ? drop_target.path : [1],
|
|
48
49
|
false,
|
|
49
50
|
"horizontal",
|
|
50
51
|
);
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
if (row < SPLIT_ROOT_EDGE_TOLERANCE) {
|
|
54
|
+
if (row < physics.SPLIT_ROOT_EDGE_TOLERANCE) {
|
|
54
55
|
return insert_root_edge(panel, slot, drop_target, [0], true, "vertical");
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
if (row > 1 - SPLIT_ROOT_EDGE_TOLERANCE) {
|
|
58
|
-
return insert_root_edge(
|
|
58
|
+
if (row > 1 - physics.SPLIT_ROOT_EDGE_TOLERANCE) {
|
|
59
|
+
return insert_root_edge(
|
|
60
|
+
panel,
|
|
61
|
+
slot,
|
|
62
|
+
drop_target,
|
|
63
|
+
drop_target.path.length > 0 ? drop_target.path : [1],
|
|
64
|
+
false,
|
|
65
|
+
"vertical",
|
|
66
|
+
);
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
// Check panel edges
|
|
62
70
|
const is_column_edge =
|
|
63
|
-
drop_target.column_offset < SPLIT_EDGE_TOLERANCE ||
|
|
64
|
-
drop_target.column_offset > 1 - SPLIT_EDGE_TOLERANCE;
|
|
71
|
+
drop_target.column_offset < physics.SPLIT_EDGE_TOLERANCE ||
|
|
72
|
+
drop_target.column_offset > 1 - physics.SPLIT_EDGE_TOLERANCE;
|
|
65
73
|
|
|
66
74
|
const is_row_edge =
|
|
67
|
-
drop_target.row_offset < SPLIT_EDGE_TOLERANCE ||
|
|
68
|
-
drop_target.row_offset > 1 - SPLIT_EDGE_TOLERANCE;
|
|
75
|
+
drop_target.row_offset < physics.SPLIT_EDGE_TOLERANCE ||
|
|
76
|
+
drop_target.row_offset > 1 - physics.SPLIT_EDGE_TOLERANCE;
|
|
69
77
|
|
|
70
78
|
// If both edges triggered, choose closer axis
|
|
71
79
|
if (is_column_edge && is_row_edge) {
|
|
@@ -86,8 +94,8 @@ export function calculate_edge(
|
|
|
86
94
|
slot,
|
|
87
95
|
drop_target,
|
|
88
96
|
use_column
|
|
89
|
-
? drop_target.column_offset < SPLIT_EDGE_TOLERANCE
|
|
90
|
-
: drop_target.row_offset < SPLIT_EDGE_TOLERANCE,
|
|
97
|
+
? drop_target.column_offset < physics.SPLIT_EDGE_TOLERANCE
|
|
98
|
+
: drop_target.row_offset < physics.SPLIT_EDGE_TOLERANCE,
|
|
91
99
|
use_column ? "horizontal" : "vertical",
|
|
92
100
|
);
|
|
93
101
|
}
|
|
@@ -97,7 +105,7 @@ export function calculate_edge(
|
|
|
97
105
|
panel,
|
|
98
106
|
slot,
|
|
99
107
|
drop_target,
|
|
100
|
-
drop_target.column_offset < SPLIT_EDGE_TOLERANCE,
|
|
108
|
+
drop_target.column_offset < physics.SPLIT_EDGE_TOLERANCE,
|
|
101
109
|
"horizontal",
|
|
102
110
|
);
|
|
103
111
|
}
|
|
@@ -107,7 +115,7 @@ export function calculate_edge(
|
|
|
107
115
|
panel,
|
|
108
116
|
slot,
|
|
109
117
|
drop_target,
|
|
110
|
-
drop_target.row_offset < SPLIT_EDGE_TOLERANCE,
|
|
118
|
+
drop_target.row_offset < physics.SPLIT_EDGE_TOLERANCE,
|
|
111
119
|
"vertical",
|
|
112
120
|
);
|
|
113
121
|
}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
// ┃ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * ┃
|
|
10
10
|
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
11
11
|
|
|
12
|
-
import { GRID_DIVIDER_SIZE } from "./constants.ts";
|
|
13
12
|
import type { LayoutPath, LayoutDivider, Layout, ViewWindow } from "./types.ts";
|
|
14
13
|
|
|
15
14
|
const VIEW_WINDOW = {
|
|
@@ -42,21 +41,21 @@ export function calculate_intersection(
|
|
|
42
41
|
column: number,
|
|
43
42
|
row: number,
|
|
44
43
|
layout: Layout,
|
|
45
|
-
check_dividers?: DOMRect,
|
|
44
|
+
check_dividers?: { rect: DOMRect; size: number },
|
|
46
45
|
): LayoutPath | null | LayoutDivider;
|
|
47
46
|
|
|
48
47
|
export function calculate_intersection(
|
|
49
48
|
column: number,
|
|
50
49
|
row: number,
|
|
51
50
|
layout: Layout,
|
|
52
|
-
check_dividers?: DOMRect | null,
|
|
51
|
+
check_dividers?: { rect: DOMRect; size: number } | null,
|
|
53
52
|
): LayoutPath | null | LayoutDivider;
|
|
54
53
|
|
|
55
54
|
export function calculate_intersection(
|
|
56
55
|
column: number,
|
|
57
56
|
row: number,
|
|
58
57
|
layout: Layout,
|
|
59
|
-
check_dividers: DOMRect | null = null,
|
|
58
|
+
check_dividers: { rect: DOMRect; size: number } | null = null,
|
|
60
59
|
): LayoutPath | null | LayoutDivider {
|
|
61
60
|
return calculate_intersection_recursive(column, row, layout, check_dividers);
|
|
62
61
|
}
|
|
@@ -65,7 +64,7 @@ function calculate_intersection_recursive(
|
|
|
65
64
|
column: number,
|
|
66
65
|
row: number,
|
|
67
66
|
panel: Layout,
|
|
68
|
-
check_dividers: DOMRect | null,
|
|
67
|
+
check_dividers: { rect: DOMRect; size: number } | null,
|
|
69
68
|
parent_orientation: "horizontal" | "vertical" | null = null,
|
|
70
69
|
view_window: ViewWindow = structuredClone(VIEW_WINDOW),
|
|
71
70
|
path: number[] = [],
|
|
@@ -99,7 +98,10 @@ function calculate_intersection_recursive(
|
|
|
99
98
|
const position = is_vertical ? row : column;
|
|
100
99
|
const start_key = is_vertical ? "row_start" : "col_start";
|
|
101
100
|
const end_key = is_vertical ? "row_end" : "col_end";
|
|
102
|
-
const rect_dim = is_vertical
|
|
101
|
+
const rect_dim = is_vertical
|
|
102
|
+
? check_dividers?.rect?.height
|
|
103
|
+
: check_dividers?.rect?.width;
|
|
104
|
+
|
|
103
105
|
let current_pos = view_window[start_key];
|
|
104
106
|
const total_size = view_window[end_key] - view_window[start_key];
|
|
105
107
|
for (let i = 0; i < panel.children.length; i++) {
|
|
@@ -107,7 +109,7 @@ function calculate_intersection_recursive(
|
|
|
107
109
|
|
|
108
110
|
// Check if position is on a divider
|
|
109
111
|
if (check_dividers && rect_dim) {
|
|
110
|
-
const divider_threshold =
|
|
112
|
+
const divider_threshold = check_dividers.size / rect_dim;
|
|
111
113
|
if (Math.abs(position - next_pos) < divider_threshold) {
|
|
112
114
|
return {
|
|
113
115
|
path: [...path, i],
|
package/src/layout/constants.ts
CHANGED
|
@@ -12,52 +12,108 @@
|
|
|
12
12
|
import type { OverlayMode } from "./types";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Instance-specific constants which define the behavior and rendering details
|
|
16
|
+
* of a `<regular-layout>`.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export interface Physics {
|
|
19
|
+
/**
|
|
20
|
+
* The prefix to use for `CustomEvent`s generated by `regular-layout`, e.g.
|
|
21
|
+
* `"regular-layout-before-update"`.
|
|
22
|
+
*/
|
|
23
|
+
CUSTOM_EVENT_NAME_PREFIX: string;
|
|
19
24
|
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The attribute name to use for matching child `Element`s to grid
|
|
27
|
+
* positions.
|
|
28
|
+
*/
|
|
29
|
+
CHILD_ATTRIBUTE_NAME: string;
|
|
24
30
|
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The minimum number of pixels the mouse must move to be considered a drag.
|
|
33
|
+
*/
|
|
34
|
+
MIN_DRAG_DISTANCE: number;
|
|
29
35
|
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export const MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD = 0.15;
|
|
36
|
+
/**
|
|
37
|
+
* Should floating point pixel calculations be rounded. Useful for testing.
|
|
38
|
+
*/
|
|
39
|
+
SHOULD_ROUND: boolean;
|
|
35
40
|
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Class name to use for child elements in overlay position (dragging).
|
|
43
|
+
*/
|
|
44
|
+
OVERLAY_CLASSNAME: string;
|
|
40
45
|
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export const SPLIT_ROOT_EDGE_TOLERANCE = 0.01;
|
|
46
|
+
/**
|
|
47
|
+
* The percentage of the maximum resize distance that will be clamped.
|
|
48
|
+
*/
|
|
49
|
+
MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD: number;
|
|
46
50
|
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* this value are treated as the same position to avoid redundant grid tracks.
|
|
52
|
-
*/
|
|
53
|
-
export const GRID_TRACK_COLLAPSE_TOLERANCE = 0.001;
|
|
51
|
+
/**
|
|
52
|
+
* Threshold from panel edge that is considered a split vs drop action.
|
|
53
|
+
*/
|
|
54
|
+
SPLIT_EDGE_TOLERANCE: number;
|
|
54
55
|
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Threshold from _container_ edge that is considered a split action on the root
|
|
58
|
+
* node.
|
|
59
|
+
*/
|
|
60
|
+
SPLIT_ROOT_EDGE_TOLERANCE: number;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Tolerance threshold for considering two grid track positions as identical.
|
|
64
|
+
*
|
|
65
|
+
* When collecting and deduplicating track positions, any positions closer than
|
|
66
|
+
* this value are treated as the same position to avoid redundant grid tracks.
|
|
67
|
+
*/
|
|
68
|
+
GRID_TRACK_COLLAPSE_TOLERANCE: number;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The overlay default behavior.
|
|
72
|
+
*/
|
|
73
|
+
OVERLAY_DEFAULT: OverlayMode;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Width of split panel dividers in pixels (for hit-test purposes).
|
|
77
|
+
*/
|
|
78
|
+
GRID_DIVIDER_SIZE: number;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Whether the grid should trigger column resize if the grid itself is not
|
|
82
|
+
* the `event.target`.
|
|
83
|
+
*/
|
|
84
|
+
GRID_DIVIDER_CHECK_TARGET: boolean;
|
|
85
|
+
}
|
|
59
86
|
|
|
60
87
|
/**
|
|
61
|
-
*
|
|
88
|
+
* Like `GlobalPhysics`, but suitable for partial definition for incremental
|
|
89
|
+
* updates.
|
|
62
90
|
*/
|
|
63
|
-
export
|
|
91
|
+
export interface PhysicsUpdate {
|
|
92
|
+
CUSTOM_EVENT_NAME_PREFIX?: string;
|
|
93
|
+
CHILD_ATTRIBUTE_NAME?: string;
|
|
94
|
+
MIN_DRAG_DISTANCE?: number;
|
|
95
|
+
SHOULD_ROUND?: boolean;
|
|
96
|
+
OVERLAY_CLASSNAME?: string;
|
|
97
|
+
MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD?: number;
|
|
98
|
+
SPLIT_EDGE_TOLERANCE?: number;
|
|
99
|
+
SPLIT_ROOT_EDGE_TOLERANCE?: number;
|
|
100
|
+
GRID_TRACK_COLLAPSE_TOLERANCE?: number;
|
|
101
|
+
OVERLAY_DEFAULT?: OverlayMode;
|
|
102
|
+
GRID_DIVIDER_SIZE?: number;
|
|
103
|
+
GRID_DIVIDER_CHECK_TARGET?: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const DEFAULT_PHYSICS: Physics = Object.freeze({
|
|
107
|
+
CUSTOM_EVENT_NAME_PREFIX: "regular-layout",
|
|
108
|
+
CHILD_ATTRIBUTE_NAME: "name",
|
|
109
|
+
MIN_DRAG_DISTANCE: 10,
|
|
110
|
+
SHOULD_ROUND: false,
|
|
111
|
+
OVERLAY_CLASSNAME: "overlay",
|
|
112
|
+
MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD: 0.15,
|
|
113
|
+
SPLIT_EDGE_TOLERANCE: 0.25,
|
|
114
|
+
SPLIT_ROOT_EDGE_TOLERANCE: 0.01,
|
|
115
|
+
GRID_TRACK_COLLAPSE_TOLERANCE: 0.001,
|
|
116
|
+
OVERLAY_DEFAULT: "absolute",
|
|
117
|
+
GRID_DIVIDER_SIZE: 6,
|
|
118
|
+
GRID_DIVIDER_CHECK_TARGET: true,
|
|
119
|
+
});
|