-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.ts
More file actions
35 lines (30 loc) · 940 Bytes
/
util.ts
File metadata and controls
35 lines (30 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function GetRectSize(minX: number, minY: number, maxX: number, maxY: number)
{
return [Math.abs(minX - maxX) + 1, Math.abs(minY - maxY) + 1];
}
type RectFunction = (x: number, y: number, coordX: number, coordY: number) => void;
function IterateThroughRect(func: RectFunction, minX: number, minY: number, maxX: number, maxY: number)
{
let [sx, sy] = GetRectSize(minX, minY, maxX, maxY);
let actualMinX = Math.min(minX, maxX);
let actualMinY = Math.min(minY, maxY);
for (let y = 0; y < sy; y++)
{
for (let x = 0; x < sx; x++)
{
func(x, y, x + actualMinX, y + actualMinY);
}
}
}
function ToggleTabindexRecursive(parent: Element, value: boolean)
{
if (value) {
parent.removeAttribute("tabindex");
}
else {
parent.setAttribute("tabindex", "-1");
}
for (let child of parent.children) {
ToggleTabindexRecursive(child, value);
}
}