tiny-essentials 1.14.0 โ 1.15.0
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/v1/TinyBasicsEs.js +496 -6
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.js +81 -6
- package/dist/v1/TinyEssentials.js +496 -6
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyUploadClicker.js +82 -6
- package/dist/v1/basics/collision.cjs +413 -0
- package/dist/v1/basics/collision.d.mts +187 -0
- package/dist/v1/basics/collision.mjs +350 -0
- package/dist/v1/basics/html.cjs +84 -6
- package/dist/v1/basics/html.d.mts +25 -0
- package/dist/v1/basics/html.mjs +74 -4
- package/dist/v1/basics/index.cjs +21 -0
- package/dist/v1/basics/index.d.mts +21 -1
- package/dist/v1/basics/index.mjs +3 -2
- package/dist/v1/index.cjs +21 -0
- package/dist/v1/index.d.mts +21 -1
- package/dist/v1/index.mjs +3 -2
- package/docs/v1/README.md +1 -0
- package/docs/v1/basics/collision.md +237 -0
- package/docs/v1/basics/html.md +27 -1
- package/package.json +5 -2
package/dist/v1/basics/index.mjs
CHANGED
|
@@ -2,9 +2,10 @@ import arraySortPositions from '../../legacy/libs/arraySortPositions.mjs';
|
|
|
2
2
|
import asyncReplace from '../../legacy/libs/replaceAsync.mjs';
|
|
3
3
|
import { shuffleArray } from './array.mjs';
|
|
4
4
|
import { formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration } from './clock.mjs';
|
|
5
|
-
import { areHtmlElsColliding, readJsonBlob, saveJsonFile, fetchJson, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, installWindowHiddenScript, readFileBlob, readBase64Blob, } from './html.mjs';
|
|
5
|
+
import { areHtmlElsColliding, readJsonBlob, saveJsonFile, fetchJson, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, installWindowHiddenScript, readFileBlob, readBase64Blob, isInViewport, isScrolledIntoView, } from './html.mjs';
|
|
6
6
|
import { countObj, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, isJsonObject, } from './objFilter.mjs';
|
|
7
7
|
import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, } from './fullScreen.mjs';
|
|
8
8
|
import { formatBytes, genFibonacciSeq, getAge, getSimplePerc, ruleOfThree } from './simpleMath.mjs';
|
|
9
9
|
import { addAiMarkerShortcut, safeTextTrim, toTitleCase, toTitleCaseLowerFirst } from './text.mjs';
|
|
10
|
-
|
|
10
|
+
import { areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, } from './collision.mjs';
|
|
11
|
+
export { areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, isInViewport, isScrolledIntoView, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, fetchJson, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|
package/dist/v1/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var asyncFuncs = require('./fileManager/asyncFuncs.cjs');
|
|
|
21
21
|
var TinyDragger = require('./libs/TinyDragger.cjs');
|
|
22
22
|
var TinyDomReadyManager = require('./libs/TinyDomReadyManager.cjs');
|
|
23
23
|
var TinyNotifications = require('./libs/TinyNotifications.cjs');
|
|
24
|
+
var collision = require('./basics/collision.cjs');
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
|
|
@@ -67,6 +68,8 @@ exports.getHtmlElBordersWidth = html.getHtmlElBordersWidth;
|
|
|
67
68
|
exports.getHtmlElMargin = html.getHtmlElMargin;
|
|
68
69
|
exports.getHtmlElPadding = html.getHtmlElPadding;
|
|
69
70
|
exports.installWindowHiddenScript = html.installWindowHiddenScript;
|
|
71
|
+
exports.isInViewport = html.isInViewport;
|
|
72
|
+
exports.isScrolledIntoView = html.isScrolledIntoView;
|
|
70
73
|
exports.readBase64Blob = html.readBase64Blob;
|
|
71
74
|
exports.readFileBlob = html.readFileBlob;
|
|
72
75
|
exports.readJsonBlob = html.readJsonBlob;
|
|
@@ -103,3 +106,21 @@ exports.listFilesAsync = asyncFuncs.listFilesAsync;
|
|
|
103
106
|
exports.TinyDragger = TinyDragger;
|
|
104
107
|
exports.TinyDomReadyManager = TinyDomReadyManager;
|
|
105
108
|
exports.TinyNotifications = TinyNotifications;
|
|
109
|
+
exports.areElsCollBottom = collision.areElsCollBottom;
|
|
110
|
+
exports.areElsCollLeft = collision.areElsCollLeft;
|
|
111
|
+
exports.areElsCollPerfBottom = collision.areElsCollPerfBottom;
|
|
112
|
+
exports.areElsCollPerfLeft = collision.areElsCollPerfLeft;
|
|
113
|
+
exports.areElsCollPerfRight = collision.areElsCollPerfRight;
|
|
114
|
+
exports.areElsCollPerfTop = collision.areElsCollPerfTop;
|
|
115
|
+
exports.areElsCollRight = collision.areElsCollRight;
|
|
116
|
+
exports.areElsCollTop = collision.areElsCollTop;
|
|
117
|
+
exports.areElsColliding = collision.areElsColliding;
|
|
118
|
+
exports.areElsPerfColliding = collision.areElsPerfColliding;
|
|
119
|
+
exports.getElsCollDetails = collision.getElsCollDetails;
|
|
120
|
+
exports.getElsCollDirDepth = collision.getElsCollDirDepth;
|
|
121
|
+
exports.getElsCollOverlap = collision.getElsCollOverlap;
|
|
122
|
+
exports.getElsCollOverlapPos = collision.getElsCollOverlapPos;
|
|
123
|
+
exports.getElsColliding = collision.getElsColliding;
|
|
124
|
+
exports.getElsPerfColliding = collision.getElsPerfColliding;
|
|
125
|
+
exports.getElsRelativeCenterOffset = collision.getElsRelativeCenterOffset;
|
|
126
|
+
exports.getRectCenter = collision.getRectCenter;
|
package/dist/v1/index.d.mts
CHANGED
|
@@ -8,6 +8,26 @@ import TinyRateLimiter from './libs/TinyRateLimiter.mjs';
|
|
|
8
8
|
import ColorSafeStringify from './libs/ColorSafeStringify.mjs';
|
|
9
9
|
import TinyPromiseQueue from './libs/TinyPromiseQueue.mjs';
|
|
10
10
|
import TinyLevelUp from '../legacy/libs/userLevel.mjs';
|
|
11
|
+
import { areElsCollTop } from './basics/collision.mjs';
|
|
12
|
+
import { areElsCollBottom } from './basics/collision.mjs';
|
|
13
|
+
import { areElsCollLeft } from './basics/collision.mjs';
|
|
14
|
+
import { areElsCollRight } from './basics/collision.mjs';
|
|
15
|
+
import { areElsCollPerfTop } from './basics/collision.mjs';
|
|
16
|
+
import { areElsCollPerfBottom } from './basics/collision.mjs';
|
|
17
|
+
import { areElsCollPerfLeft } from './basics/collision.mjs';
|
|
18
|
+
import { areElsCollPerfRight } from './basics/collision.mjs';
|
|
19
|
+
import { areElsColliding } from './basics/collision.mjs';
|
|
20
|
+
import { areElsPerfColliding } from './basics/collision.mjs';
|
|
21
|
+
import { getElsColliding } from './basics/collision.mjs';
|
|
22
|
+
import { getElsPerfColliding } from './basics/collision.mjs';
|
|
23
|
+
import { getElsCollOverlap } from './basics/collision.mjs';
|
|
24
|
+
import { getElsCollOverlapPos } from './basics/collision.mjs';
|
|
25
|
+
import { getRectCenter } from './basics/collision.mjs';
|
|
26
|
+
import { getElsRelativeCenterOffset } from './basics/collision.mjs';
|
|
27
|
+
import { getElsCollDirDepth } from './basics/collision.mjs';
|
|
28
|
+
import { getElsCollDetails } from './basics/collision.mjs';
|
|
29
|
+
import { isInViewport } from './basics/html.mjs';
|
|
30
|
+
import { isScrolledIntoView } from './basics/html.mjs';
|
|
11
31
|
import { safeTextTrim } from './basics/text.mjs';
|
|
12
32
|
import { installWindowHiddenScript } from './basics/html.mjs';
|
|
13
33
|
import { genFibonacciSeq } from './basics/simpleMath.mjs';
|
|
@@ -77,5 +97,5 @@ import { getTimeDuration } from './basics/clock.mjs';
|
|
|
77
97
|
import { shuffleArray } from './basics/array.mjs';
|
|
78
98
|
import { toTitleCase } from './basics/text.mjs';
|
|
79
99
|
import { toTitleCaseLowerFirst } from './basics/text.mjs';
|
|
80
|
-
export { TinyNotifications, TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, getLatestBackupPath, fetchJson, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
100
|
+
export { TinyNotifications, TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, isInViewport, isScrolledIntoView, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, getLatestBackupPath, fetchJson, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
81
101
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/v1/index.mjs
CHANGED
|
@@ -12,11 +12,12 @@ import TinyPromiseQueue from './libs/TinyPromiseQueue.mjs';
|
|
|
12
12
|
import TinyRateLimiter from './libs/TinyRateLimiter.mjs';
|
|
13
13
|
import TinyNotifyCenter from './libs/TinyNotifyCenter.mjs';
|
|
14
14
|
import TinyToastNotify from './libs/TinyToastNotify.mjs';
|
|
15
|
-
import { areHtmlElsColliding, readJsonBlob, saveJsonFile, fetchJson, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, installWindowHiddenScript, readFileBlob, readBase64Blob, } from './basics/html.mjs';
|
|
15
|
+
import { areHtmlElsColliding, readJsonBlob, saveJsonFile, fetchJson, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, installWindowHiddenScript, readFileBlob, readBase64Blob, isInViewport, isScrolledIntoView, } from './basics/html.mjs';
|
|
16
16
|
import TinyDragDropDetector from './libs/TinyDragDropDetector.mjs';
|
|
17
17
|
import { readJsonFile, writeJsonFile, ensureDirectory, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, getLatestBackupPath, } from './fileManager/normalFuncs.mjs';
|
|
18
18
|
import { listFilesAsync, listDirsAsync, clearDirectoryAsync, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, } from './fileManager/asyncFuncs.mjs';
|
|
19
19
|
import TinyDragger from './libs/TinyDragger.mjs';
|
|
20
20
|
import TinyDomReadyManager from './libs/TinyDomReadyManager.mjs';
|
|
21
21
|
import TinyNotifications from './libs/TinyNotifications.mjs';
|
|
22
|
-
|
|
22
|
+
import { areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, } from './basics/collision.mjs';
|
|
23
|
+
export { TinyNotifications, TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, isInViewport, isScrolledIntoView, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, getLatestBackupPath, fetchJson, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, areHtmlElsColliding, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|
package/docs/v1/README.md
CHANGED
|
@@ -20,6 +20,7 @@ This folder contains the core scripts we have worked on so far. Each file is a m
|
|
|
20
20
|
- ๐ **[asyncReplace](./basics/asyncReplace.md)** โ Asynchronously replaces matches in a string using a regex and an async function.
|
|
21
21
|
- ๐ผ๏ธ **[html](./basics/html.md)** โ Utilities for handling DOM element interactions like collision detection and basic element manipulation.
|
|
22
22
|
- ๐บ **[fullScreen](./basics/fullScreen.md)** โ A complete fullscreen API manager with detection, event handling, and cross-browser compatibility.
|
|
23
|
+
- ๐งฑ **[collision](./basics/collision.md)** โ Full-featured rectangle collision detection system with directional analysis, depth calculation, and center offset metrics.
|
|
23
24
|
|
|
24
25
|
### 2. **`libs/`**
|
|
25
26
|
- ๐๏ธ **[TinyPromiseQueue](./libs/TinyPromiseQueue.md)** โ A class that allows sequential execution of asynchronous tasks, supporting task delays, cancellation, and queue management.
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# ๐ฆ Collision Detection Module
|
|
2
|
+
|
|
3
|
+
This module provides a complete and flexible system for detecting collisions between rectangles (like DOM elements), extracting direction, depth, and center alignment data.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ Type Definitions
|
|
8
|
+
|
|
9
|
+
### `Dirs`
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
'top' | 'bottom' | 'left' | 'right'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
๐ A direction relative to a rectangle. Represents one of the four cardinal sides.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### `CollDirs`
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
{
|
|
23
|
+
in: Dirs | 'center' | null;
|
|
24
|
+
x: Dirs | null;
|
|
25
|
+
y: Dirs | null;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
๐ฆ Represents all directional aspects of a collision:
|
|
30
|
+
|
|
31
|
+
* `in`: Dominant entry direction (`null` if no collision, `'center'` if perfectly aligned).
|
|
32
|
+
* `x`: Collision bias on X axis.
|
|
33
|
+
* `y`: Collision bias on Y axis.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### `NegCollDirs`
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
{
|
|
41
|
+
x: Dirs | null;
|
|
42
|
+
y: Dirs | null;
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
โ Negative collision flags indicating **gap** instead of overlap.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### `CollData`
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
{
|
|
54
|
+
top: number;
|
|
55
|
+
bottom: number;
|
|
56
|
+
left: number;
|
|
57
|
+
right: number;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
๐ Collision depth (in pixels) from each side of `rect2` into `rect1`.
|
|
62
|
+
|
|
63
|
+
* Positive values = overlap
|
|
64
|
+
* Negative values = no collision (gap)
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### `CollCenter`
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
{
|
|
72
|
+
x: number;
|
|
73
|
+
y: number;
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
๐ฏ Offset from the center of `rect1` to the center of `rect2`.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
### `ObjRect`
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
{
|
|
85
|
+
height: number;
|
|
86
|
+
width: number;
|
|
87
|
+
top: number;
|
|
88
|
+
bottom: number;
|
|
89
|
+
left: number;
|
|
90
|
+
right: number;
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
๐ฆ Generic rectangle object, similar to `DOMRect`.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## ๐ Collision Checks
|
|
99
|
+
|
|
100
|
+
### Loose Collision (Partial Overlap Only)
|
|
101
|
+
|
|
102
|
+
| Function | Description |
|
|
103
|
+
| -------------------------------- | --------------------------------------- |
|
|
104
|
+
| `areElsCollTop(rect1, rect2)` | `rect1` is **above** `rect2` |
|
|
105
|
+
| `areElsCollBottom(rect1, rect2)` | `rect1` is **below** `rect2` |
|
|
106
|
+
| `areElsCollLeft(rect1, rect2)` | `rect1` is **left of** `rect2` |
|
|
107
|
+
| `areElsCollRight(rect1, rect2)` | `rect1` is **right of** `rect2` |
|
|
108
|
+
| `areElsColliding(rect1, rect2)` | Returns `true` if **any side overlaps** |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### Perfect Collision (Touch or Overlap)
|
|
113
|
+
|
|
114
|
+
| Function | Description |
|
|
115
|
+
| ------------------------------------ | -------------------------------------------------- |
|
|
116
|
+
| `areElsCollPerfTop(rect1, rect2)` | `rect1` is **fully above** or touching `rect2` |
|
|
117
|
+
| `areElsCollPerfBottom(rect1, rect2)` | `rect1` is **fully below** or touching `rect2` |
|
|
118
|
+
| `areElsCollPerfLeft(rect1, rect2)` | `rect1` is **fully left** or touching `rect2` |
|
|
119
|
+
| `areElsCollPerfRight(rect1, rect2)` | `rect1` is **fully right** or touching `rect2` |
|
|
120
|
+
| `areElsPerfColliding(rect1, rect2)` | Returns `true` if there's **any overlap or touch** |
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### Collision Direction (Single Side Detection)
|
|
125
|
+
|
|
126
|
+
| Function | Returns |
|
|
127
|
+
| ----------------------------------- | -------------------------------------------------- |
|
|
128
|
+
| `getElsColliding(rect1, rect2)` | `'left'`, `'right'`, `'top'`, `'bottom'` or `null` |
|
|
129
|
+
| `getElsPerfColliding(rect1, rect2)` | Same as above, but includes **touch detection** |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## ๐ฌ Overlap & Direction
|
|
134
|
+
|
|
135
|
+
### `getElsCollOverlap(rect1, rect2)`
|
|
136
|
+
|
|
137
|
+
๐ Returns the depth of overlap between two rectangles:
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
{
|
|
141
|
+
overlapLeft,
|
|
142
|
+
overlapRight,
|
|
143
|
+
overlapTop,
|
|
144
|
+
overlapBottom
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
### `getElsCollOverlapPos({ overlapLeft, overlapRight, overlapTop, overlapBottom })`
|
|
151
|
+
|
|
152
|
+
๐ Determines which axis and direction has the strongest collision.
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
{
|
|
156
|
+
dirX: 'left' | 'right',
|
|
157
|
+
dirY: 'top' | 'bottom'
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## ๐ฏ Center Detection
|
|
164
|
+
|
|
165
|
+
### `getRectCenter(rect)`
|
|
166
|
+
|
|
167
|
+
Returns the **center X and Y coordinates** of a rectangle.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### `getElsRelativeCenterOffset(rect1, rect2)`
|
|
172
|
+
|
|
173
|
+
Returns the distance from `rect1`'s center to `rect2`'s center:
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
{
|
|
177
|
+
x: number,
|
|
178
|
+
y: number
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
โ
Values are `0` when centers are aligned.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## ๐ง Direction & Depth
|
|
187
|
+
|
|
188
|
+
### `getElsCollDirDepth(rect1, rect2)`
|
|
189
|
+
|
|
190
|
+
Detects:
|
|
191
|
+
|
|
192
|
+
* Which axis has the dominant collision
|
|
193
|
+
* Overlap depths
|
|
194
|
+
|
|
195
|
+
```js
|
|
196
|
+
{
|
|
197
|
+
inDir: 'left' | 'right' | 'top' | 'bottom' | null,
|
|
198
|
+
dirX: 'left' | 'right' | null,
|
|
199
|
+
dirY: 'top' | 'bottom' | null,
|
|
200
|
+
depthX: number,
|
|
201
|
+
depthY: number
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
### `getElsCollDetails(rect1, rect2)`
|
|
208
|
+
|
|
209
|
+
๐ Full analysis of the collision:
|
|
210
|
+
|
|
211
|
+
* Depth of overlap
|
|
212
|
+
* Direction of entry
|
|
213
|
+
* Negative axis gaps
|
|
214
|
+
* Center hit detection
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
{
|
|
218
|
+
depth: CollData,
|
|
219
|
+
dirs: CollDirs,
|
|
220
|
+
isNeg: NegCollDirs
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## ๐งช Example Use
|
|
227
|
+
|
|
228
|
+
```js
|
|
229
|
+
const box = element1.getBoundingClientRect();
|
|
230
|
+
const wall = element2.getBoundingClientRect();
|
|
231
|
+
|
|
232
|
+
const result = getElsCollDetails(box, wall);
|
|
233
|
+
|
|
234
|
+
console.log(result.depth); // { top, bottom, left, right }
|
|
235
|
+
console.log(result.dirs.in); // e.g. 'left'
|
|
236
|
+
console.log(result.isNeg); // e.g. { x: 'left', y: null }
|
|
237
|
+
```
|
package/docs/v1/basics/html.md
CHANGED
|
@@ -136,7 +136,7 @@ input.addEventListener('change', async () => {
|
|
|
136
136
|
|
|
137
137
|
### ๐ `readJsonBlob(file: File): Promise<any>`
|
|
138
138
|
|
|
139
|
-
Reads and parses a JSON file using the
|
|
139
|
+
Reads and parses a JSON file using the FileReader API.
|
|
140
140
|
|
|
141
141
|
#### ๐ฅ Parameters
|
|
142
142
|
|
|
@@ -279,6 +279,32 @@ getHtmlElBordersWidth(el: Element): HtmlElBoxSides
|
|
|
279
279
|
|
|
280
280
|
---
|
|
281
281
|
|
|
282
|
+
### ๐๏ธ `isInViewport(element)`
|
|
283
|
+
|
|
284
|
+
๐ Checks if an element is **partially visible** in the current viewport.
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
isInViewport(element: HTMLElement): boolean
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
* `element`: The DOM element to check.
|
|
291
|
+
* **Returns**: `true` if the element is at least partially visible; `false` otherwise.
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
### โ
`isScrolledIntoView(element)`
|
|
296
|
+
|
|
297
|
+
๐ฆ Checks if an element is **fully visible** (top and bottom) within the viewport.
|
|
298
|
+
|
|
299
|
+
```js
|
|
300
|
+
isScrolledIntoView(element: HTMLElement): boolean
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
* `element`: The DOM element to check.
|
|
304
|
+
* **Returns**: `true` if the entire element is within the viewport; `false` otherwise.
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
282
308
|
### ๐ณ `getHtmlElBorders(el)`
|
|
283
309
|
|
|
284
310
|
๐ Returns the total **border size** of an element using `border{Side}` shorthand values from computed styles.
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
|
|
7
7
|
"test:js": "npx babel-node test/index.js",
|
|
8
8
|
"test:cjs": "node test/index.cjs",
|
|
9
9
|
"test:mjs": "node test/index.mjs",
|
|
10
|
+
"test:mjs:web": "node test/express.mjs",
|
|
10
11
|
"test:mjs:promisequeue": "node test/index.mjs promiseQueue",
|
|
11
12
|
"test:mjs:objtype": "node test/index.mjs objType",
|
|
12
13
|
"test:mjs:jsoncolor": "node test/index.mjs colorStringify",
|
|
@@ -97,11 +98,13 @@
|
|
|
97
98
|
"byte-length": "^1.0.2",
|
|
98
99
|
"clone": "^2.1.2",
|
|
99
100
|
"compare-versions": "^6.1.1",
|
|
101
|
+
"esbuild": "^0.25.5",
|
|
100
102
|
"express": "^5.1.0",
|
|
101
103
|
"firebase": "^11.7.1",
|
|
102
104
|
"firebase-functions": "^6.3.2",
|
|
103
105
|
"latest-version": "^9.0.0",
|
|
104
106
|
"lodash": "^4.17.21",
|
|
107
|
+
"marked": "^16.0.0",
|
|
105
108
|
"md5": "^2.3.0",
|
|
106
109
|
"moment": "^2.30.1",
|
|
107
110
|
"moment-timezone": "^0.5.48",
|
|
@@ -113,7 +116,7 @@
|
|
|
113
116
|
"rollup": "^4.40.0",
|
|
114
117
|
"rollup-preserve-directives": "^1.1.3",
|
|
115
118
|
"safe-stable-stringify": "^2.5.0",
|
|
116
|
-
"sass": "^1.
|
|
119
|
+
"sass": "^1.89.2",
|
|
117
120
|
"tinycolor2": "^1.6.0",
|
|
118
121
|
"tslib": "^2.8.1",
|
|
119
122
|
"type-fest": "^4.40.0",
|