Skip to content

Commit 403c030

Browse files
committed
add useSplit doc
1 parent 12e029d commit 403c030

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

ethernet-view/src/hooks/useSplit/useSplit.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ export type SplitElement = {
1313
minLength: number;
1414
};
1515

16+
/**
17+
* The `useSplit` function in TypeScript is used to manage resizable elements with specified initial
18+
* lengths and minimum lengths in a given direction.
19+
* @param {number[] | undefined} initialLengths - The `initialLengths` parameter is an array of numbers
20+
* representing the initial lengths of the elements to be split. It can be either `undefined` or an
21+
* array of numbers. If it is `undefined`, if its length is not equal to the length of the
22+
* `minLengths` array or if its sum is not equal to 1, the `initialLengths` will be set proportionally equal.
23+
* @param {number[]} minLengths - The `minLengths` parameter in the `useSplit` function represents an
24+
* array of minimum lengths for each split element. These minimum lengths determine the smallest size
25+
* each element can be resized to. If a user tries to resize an element below its minimum length, the
26+
* element will be collapsed.
27+
* @param {Orientation} direction - The `direction` parameter in the `useSplit` function is used to
28+
* determine the orientation of the split elements. It is of type `Orientation`, which is likely an
29+
* enum or type that specifies whether the split should be horizontal or vertical. This helps in
30+
* calculating the resizing of elements based on the direction
31+
* @returns The `useSplit` function returns an array containing the `elements` state and the
32+
* `handleMouseDown` function from the `separatorEventHandler`.
33+
*/
1634
export function useSplit(initialLengths: number[] | undefined, minLengths: number[], direction: Orientation) {
1735

1836
if(!initialLengths || initialLengths.length != minLengths.length || initialLengths.reduce((prev, curr) => prev + curr, 0) != 1) {

0 commit comments

Comments
 (0)