tiny-essentials 1.16.1 → 1.17.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/legacy/crypto/decrypt.cjs +1 -0
- package/dist/legacy/crypto/decrypt.d.mts +1 -0
- package/dist/legacy/crypto/decrypt.mjs +1 -0
- package/dist/legacy/crypto/encrypt.cjs +1 -0
- package/dist/legacy/crypto/encrypt.d.mts +1 -0
- package/dist/legacy/crypto/encrypt.mjs +1 -0
- package/dist/legacy/get/decimalColor.cjs +1 -0
- package/dist/legacy/get/decimalColor.d.mts +1 -0
- package/dist/legacy/get/decimalColor.mjs +1 -0
- package/dist/legacy/get/pagination.cjs +1 -0
- package/dist/legacy/get/pagination.d.mts +1 -0
- package/dist/legacy/get/pagination.mjs +1 -0
- package/dist/legacy/get/queryUrlByName.cjs +1 -0
- package/dist/legacy/get/queryUrlByName.d.mts +1 -0
- package/dist/legacy/get/queryUrlByName.mjs +1 -0
- package/dist/legacy/get/queryUrlJSON.cjs +1 -0
- package/dist/legacy/get/queryUrlJSON.d.mts +1 -0
- package/dist/legacy/get/queryUrlJSON.mjs +1 -0
- package/dist/legacy/get/super_string_filter.cjs +1 -0
- package/dist/legacy/get/super_string_filter.d.mts +1 -0
- package/dist/legacy/get/super_string_filter.mjs +1 -0
- package/dist/legacy/get/versionCheck.cjs +1 -0
- package/dist/legacy/get/versionCheck.d.mts +1 -0
- package/dist/legacy/get/versionCheck.mjs +1 -0
- package/dist/legacy/http/HTTP-1.0.cjs +2 -0
- package/dist/legacy/http/HTTP-1.0.mjs +2 -0
- package/dist/legacy/http/auth.cjs +1 -0
- package/dist/legacy/http/auth.d.mts +1 -0
- package/dist/legacy/http/auth.mjs +1 -0
- package/dist/legacy/http/check_domain.cjs +11 -0
- package/dist/legacy/http/check_domain.d.mts +3 -0
- package/dist/legacy/http/check_domain.mjs +11 -0
- package/dist/legacy/http/csrfTokenAnalyze.cjs +1 -0
- package/dist/legacy/http/csrfTokenAnalyze.d.mts +1 -0
- package/dist/legacy/http/csrfTokenAnalyze.mjs +1 -0
- package/dist/legacy/http/domainValidator.cjs +1 -0
- package/dist/legacy/http/domainValidator.d.mts +1 -0
- package/dist/legacy/http/domainValidator.mjs +1 -0
- package/dist/legacy/http/errorsCallback.cjs +1 -0
- package/dist/legacy/http/errorsCallback.d.mts +1 -0
- package/dist/legacy/http/errorsCallback.mjs +1 -0
- package/dist/legacy/http/fetch/json.cjs +1 -0
- package/dist/legacy/http/fetch/json.d.mts +1 -0
- package/dist/legacy/http/fetch/json.mjs +1 -0
- package/dist/legacy/http/fetch/text.cjs +1 -0
- package/dist/legacy/http/fetch/text.d.mts +1 -0
- package/dist/legacy/http/fetch/text.mjs +1 -0
- package/dist/legacy/http/fileCache.cjs +1 -0
- package/dist/legacy/http/fileCache.d.mts +1 -0
- package/dist/legacy/http/fileCache.mjs +1 -0
- package/dist/legacy/http/getDomainURL.cjs +1 -0
- package/dist/legacy/http/getDomainURL.d.mts +1 -0
- package/dist/legacy/http/getDomainURL.mjs +1 -0
- package/dist/legacy/http/userIP.cjs +1 -0
- package/dist/legacy/http/userIP.d.mts +1 -0
- package/dist/legacy/http/userIP.mjs +1 -0
- package/dist/legacy/libs/capitalize.cjs +1 -0
- package/dist/legacy/libs/capitalize.d.mts +1 -0
- package/dist/legacy/libs/capitalize.mjs +1 -0
- package/dist/legacy/libs/convertBytes.cjs +2 -0
- package/dist/legacy/libs/convertBytes.mjs +2 -0
- package/dist/legacy/libs/custom_module_loader.cjs +2 -0
- package/dist/legacy/libs/custom_module_loader.mjs +2 -0
- package/dist/legacy/libs/dice.cjs +2 -0
- package/dist/legacy/libs/dice.mjs +2 -0
- package/dist/legacy/libs/markdown.cjs +1 -0
- package/dist/legacy/libs/markdown.mjs +1 -0
- package/dist/legacy/libs/percentage.cjs +1 -0
- package/dist/legacy/libs/percentage.mjs +1 -0
- package/dist/legacy/libs/regex/getLetter.cjs +2 -0
- package/dist/legacy/libs/regex/getLetter.d.mts +2 -0
- package/dist/legacy/libs/regex/getLetter.mjs +2 -0
- package/dist/legacy/libs/rule3.cjs +1 -0
- package/dist/legacy/libs/rule3.mjs +1 -0
- package/dist/legacy/momentjs/getAge.cjs +1 -0
- package/dist/legacy/momentjs/getAge.d.mts +1 -0
- package/dist/legacy/momentjs/getAge.mjs +1 -0
- package/dist/legacy/momentjs/timeDuration.cjs +1 -0
- package/dist/legacy/momentjs/timeDuration.d.mts +1 -0
- package/dist/legacy/momentjs/timeDuration.mjs +1 -0
- package/dist/legacy/socket.io/antiFlood/install.cjs +1 -0
- package/dist/legacy/socket.io/antiFlood/install.d.mts +1 -0
- package/dist/legacy/socket.io/antiFlood/install.mjs +1 -0
- package/dist/legacy/socket.io/antiFlood/verify.cjs +1 -0
- package/dist/legacy/socket.io/antiFlood/verify.d.mts +1 -0
- package/dist/legacy/socket.io/antiFlood/verify.mjs +1 -0
- package/dist/legacy/socket.io/cookie-session.cjs +1 -0
- package/dist/legacy/socket.io/cookie-session.d.mts +1 -0
- package/dist/legacy/socket.io/cookie-session.mjs +1 -0
- package/dist/legacy/socket.io/discord.cjs +1 -0
- package/dist/legacy/socket.io/discord.d.mts +1 -0
- package/dist/legacy/socket.io/discord.mjs +1 -0
- package/dist/v1/TinyAfterScrollWatcher.js +49 -26
- package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
- package/dist/v1/TinyBasicsEs.js +559 -71
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.js +486 -47
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.js +2545 -98
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.js +486 -47
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.js +6230 -0
- package/dist/v1/TinySmartScroller.min.js +1 -0
- package/dist/v1/TinyUploadClicker.js +1538 -72
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/UltraRandomMsgGen.js +995 -0
- package/dist/v1/UltraRandomMsgGen.min.js +1 -0
- package/dist/v1/basics/html.cjs +74 -24
- package/dist/v1/basics/html.d.mts +38 -15
- package/dist/v1/basics/html.mjs +63 -20
- package/dist/v1/build/TinySmartScroller.cjs +7 -0
- package/dist/v1/build/TinySmartScroller.d.mts +3 -0
- package/dist/v1/build/TinySmartScroller.mjs +2 -0
- package/dist/v1/build/UltraRandomMsgGen.cjs +7 -0
- package/dist/v1/build/UltraRandomMsgGen.d.mts +3 -0
- package/dist/v1/build/UltraRandomMsgGen.mjs +2 -0
- package/dist/v1/index.cjs +4 -0
- package/dist/v1/index.d.mts +3 -1
- package/dist/v1/index.mjs +3 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.cjs +49 -26
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +17 -14
- package/dist/v1/libs/TinyAfterScrollWatcher.mjs +50 -24
- package/dist/v1/libs/TinyHtml.cjs +486 -47
- package/dist/v1/libs/TinyHtml.d.mts +352 -139
- package/dist/v1/libs/TinyHtml.mjs +431 -47
- package/dist/v1/libs/TinySmartScroller.cjs +976 -0
- package/dist/v1/libs/TinySmartScroller.d.mts +458 -0
- package/dist/v1/libs/TinySmartScroller.mjs +856 -0
- package/dist/v1/libs/UltraRandomMsgGen.cjs +956 -0
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +390 -0
- package/dist/v1/libs/UltraRandomMsgGen.mjs +825 -0
- package/docs/v1/README.md +2 -0
- package/docs/v1/basics/html.md +17 -2
- package/docs/v1/libs/TinyAfterScrollWatcher.md +54 -4
- package/docs/v1/libs/TinyHtml.md +197 -8
- package/docs/v1/libs/TinySmartScroller.md +523 -0
- package/docs/v1/libs/UltraRandomMsgGen.md +289 -0
- package/package.json +1 -1
package/docs/v1/README.md
CHANGED
|
@@ -35,6 +35,8 @@ This folder contains the core scripts we have worked on so far. Each file is a m
|
|
|
35
35
|
- 🕒 **[TinyDomReadyManager](./libs/TinyDomReadyManager.md)** — A readiness manager for DOM and async conditions, supporting prioritized callbacks, custom filters, and event-based or promise-based bootstrapping.
|
|
36
36
|
- 📣 **[TinyNotifications](./libs/TinyNotifications.md)** — A browser notification utility with sound support, permission management, truncation logic, default icons, and enforced validation to ensure safe and predictable usage.
|
|
37
37
|
- 🧱 **[TinyHtml](./libs/TinyHtml.md)** — A minimalist DOM utility class that offers jQuery-like methods in pure JavaScript for querying, styling, traversing, event handling, collision detection, and visibility logic — all in a lightweight and chainable interface.
|
|
38
|
+
- 🌀 **[TinySmartScroller](./libs/TinySmartScroller.md)** — A smart scroll monitor that detects user scroll behavior, visibility changes, element sizes, and automatically handles scroll preservation, bottom detection, debounce, and more.
|
|
39
|
+
- 🍮 **[UltraRandomMsgGen](./libs/UltraRandomMsgGen.md)** — A whimsical random message generator using grammar templates, word sets, emojis, and chaotic modes to craft playful text outputs.
|
|
38
40
|
|
|
39
41
|
### 3. **`fileManager/`**
|
|
40
42
|
* 📁 **[Main](./fileManager/main.md)** — A Node.js file/directory utility module with support for JSON, backups, renaming, size analysis, and more.
|
package/docs/v1/basics/html.md
CHANGED
|
@@ -140,9 +140,9 @@ const data = { name: 'Yasmin', type: 'dev' };
|
|
|
140
140
|
saveJsonFile('yasmin.json', data);
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
### 🌐 `
|
|
143
|
+
### 🌐 `fetchTemplate(...)`
|
|
144
144
|
|
|
145
|
-
Loads
|
|
145
|
+
Loads data from a remote URL using Fetch API, with support for custom HTTP methods, retries, timeouts, headers, and even external abort controllers.
|
|
146
146
|
|
|
147
147
|
#### 📥 Parameters
|
|
148
148
|
|
|
@@ -156,6 +156,21 @@ Loads and parses a JSON from a remote URL using the Fetch API, with support for
|
|
|
156
156
|
* `headers` *(object)*: Additional headers to include in the request.
|
|
157
157
|
* `body` *(object)*: Request body. If the value is a plain object, it will be automatically stringified as JSON.
|
|
158
158
|
|
|
159
|
+
#### `fetchJson(url, options?): Promise<any[] | Record<string | number | symbol, unknown>>`
|
|
160
|
+
|
|
161
|
+
Loads and parses a JSON.
|
|
162
|
+
|
|
163
|
+
* `url` *(string)*: The full URL to fetch JSON from (must start with `http://`, `https://`, `/`, `./`, or `../`).
|
|
164
|
+
* `options` *(object)* *(optional)*:
|
|
165
|
+
|
|
166
|
+
#### `fetchBlob(url, options?): Promise<any[] | Record<string | number | symbol, unknown>>`
|
|
167
|
+
|
|
168
|
+
Loads a remote file as a Blob.
|
|
169
|
+
|
|
170
|
+
* `url` *(string)*: The full URL to fetch JSON from (must start with `http://`, `https://`, `/`, `./`, or `../`).
|
|
171
|
+
* `allowedMimeTypes` Optional list of accepted MIME types (e.g., ['image/jpeg']).
|
|
172
|
+
* `options` *(object)* *(optional)*:
|
|
173
|
+
|
|
159
174
|
##### `signal` (`AbortSignal` | `null`) — *optional*
|
|
160
175
|
|
|
161
176
|
Custom abort signal. If set:
|
|
@@ -10,7 +10,8 @@ Perfect for optimizing logic that should only run **after** the user has finishe
|
|
|
10
10
|
* ✅ Works on any scrollable element or the window
|
|
11
11
|
* ⏱️ Customizable "inactivity timeout" (default: `100ms`)
|
|
12
12
|
* 🧠 Executes queued callbacks after scroll ends
|
|
13
|
-
*
|
|
13
|
+
* 🧷 Add/remove scroll listeners easily (`onScroll` / `offScroll`)
|
|
14
|
+
* 🛑 Execute logic right before after-scroll queue (`onStop`)
|
|
14
15
|
* 🧹 Cleanly destroy the instance when no longer needed
|
|
15
16
|
|
|
16
17
|
---
|
|
@@ -36,6 +37,11 @@ watcher.doAfterScroll(() => {
|
|
|
36
37
|
console.log('Scroll has stopped for 300ms!');
|
|
37
38
|
});
|
|
38
39
|
|
|
40
|
+
// Add a function to run immediately when scroll stops
|
|
41
|
+
watcher.onStop(() => {
|
|
42
|
+
console.log('User just stopped scrolling!');
|
|
43
|
+
});
|
|
44
|
+
|
|
39
45
|
// Add a custom scroll listener
|
|
40
46
|
const myScrollHandler = () => console.log('Scrolling...');
|
|
41
47
|
watcher.onScroll(myScrollHandler);
|
|
@@ -43,6 +49,9 @@ watcher.onScroll(myScrollHandler);
|
|
|
43
49
|
// Remove it later
|
|
44
50
|
watcher.offScroll(myScrollHandler);
|
|
45
51
|
|
|
52
|
+
// Also remove onStop listener
|
|
53
|
+
watcher.offStop(myStopFunction);
|
|
54
|
+
|
|
46
55
|
// Fully destroy the watcher
|
|
47
56
|
watcher.destroy();
|
|
48
57
|
```
|
|
@@ -106,6 +115,46 @@ doAfterScroll(fn: FnData): void
|
|
|
106
115
|
|
|
107
116
|
---
|
|
108
117
|
|
|
118
|
+
### 🛑 Method: `onStop(fn)`
|
|
119
|
+
|
|
120
|
+
Registers a function to be called **immediately after scrolling stops**, but **before** the `doAfterScroll` queue is executed.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
onStop(fn: FnData): void
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Parameters:
|
|
127
|
+
|
|
128
|
+
| Name | Type | Description |
|
|
129
|
+
| ---- | -------- | ----------------------------------------------- |
|
|
130
|
+
| `fn` | `FnData` | Function to call as soon as scroll has stopped. |
|
|
131
|
+
|
|
132
|
+
#### Throws:
|
|
133
|
+
|
|
134
|
+
* `TypeError` if the argument is not a function.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### 🔁 Method: `offStop(fn)`
|
|
139
|
+
|
|
140
|
+
Removes a function previously registered with `onStop`.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
offStop(fn: FnData): void
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Parameters:
|
|
147
|
+
|
|
148
|
+
| Name | Type | Description |
|
|
149
|
+
| ---- | -------- | ---------------------------------- |
|
|
150
|
+
| `fn` | `FnData` | Function to remove from onStop set |
|
|
151
|
+
|
|
152
|
+
#### Throws:
|
|
153
|
+
|
|
154
|
+
* `TypeError` if the argument is not a function.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
109
158
|
### 🧷 Method: `onScroll(fn)`
|
|
110
159
|
|
|
111
160
|
Registers a custom scroll listener on the tracked element.
|
|
@@ -176,6 +225,7 @@ type OnScrollFunc = (ev: Event) => void;
|
|
|
176
225
|
|
|
177
226
|
## 📝 Notes
|
|
178
227
|
|
|
179
|
-
*
|
|
180
|
-
* The
|
|
181
|
-
*
|
|
228
|
+
* `onStop` functions are called **before** the `doAfterScroll` queue.
|
|
229
|
+
* The `doAfterScroll` queue runs in **LIFO** order (last-in, first-out).
|
|
230
|
+
* `requestAnimationFrame` is used for efficient polling.
|
|
231
|
+
* Lower `inactivityTime` makes scroll-stop detection more responsive.
|
package/docs/v1/libs/TinyHtml.md
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
# 📚 TinyHtml Class
|
|
2
2
|
|
|
3
|
-
`TinyHtml` is a lightweight utility class that provides DOM element manipulation and querying utilities, inspired by jQuery — but with modern native browser APIs.
|
|
3
|
+
`TinyHtml` is a lightweight utility class that provides DOM element manipulation and querying utilities, inspired by jQuery — but built with modern native browser APIs.
|
|
4
4
|
|
|
5
|
-
It supports both static and instance-level operations, making it easy to work with elements
|
|
5
|
+
It supports both static and instance-level operations, making it easy to work with elements’ dimensions, collisions, and more in a readable and performant way.
|
|
6
|
+
|
|
7
|
+
Most instance methods that do not return a specific value are designed to return the `TinyHtml` instance itself, enabling **method chaining**.
|
|
8
|
+
This allows you to write fluent and expressive code like:
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
TinyHtml.createElement('div')
|
|
12
|
+
.addClass('box')
|
|
13
|
+
.setAttr('role', 'dialog')
|
|
14
|
+
.appendTo(document.body);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This design keeps your code concise while maintaining clarity and control over the DOM structure.
|
|
6
18
|
|
|
7
|
-
---
|
|
8
19
|
|
|
9
20
|
## 🧩 Type Definitions – Core Building Blocks
|
|
10
21
|
|
|
@@ -69,8 +80,28 @@ ElementAndWindow | TinyHtml
|
|
|
69
80
|
|
|
70
81
|
---
|
|
71
82
|
|
|
83
|
+
#### `TinyElementAndWinAndDoc`
|
|
84
|
+
|
|
85
|
+
Accepts both raw DOM elements, `document`, and the `window` object.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
ElementAndWinAndDoc | TinyHtml
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
72
93
|
### 🔀 Union Types
|
|
73
94
|
|
|
95
|
+
#### `ElementAndWinAndDoc`
|
|
96
|
+
|
|
97
|
+
Used for scrollable or measurable targets.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
Element | Window | Document
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
74
105
|
#### `ElementAndWindow`
|
|
75
106
|
|
|
76
107
|
Used for scrollable or measurable targets.
|
|
@@ -97,7 +128,7 @@ Flexible type for querying or filtering elements:
|
|
|
97
128
|
Values accepted by the TinyHtml constructor:
|
|
98
129
|
|
|
99
130
|
```ts
|
|
100
|
-
Window | Element | Document
|
|
131
|
+
Window | Element | Document | Text
|
|
101
132
|
```
|
|
102
133
|
|
|
103
134
|
---
|
|
@@ -271,13 +302,63 @@ HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLOptionElement
|
|
|
271
302
|
|
|
272
303
|
These methods wrap native DOM query methods and return results as `TinyHtml` instances for consistency.
|
|
273
304
|
|
|
305
|
+
### `TinyHtml.createElement(tagName, ops)`
|
|
306
|
+
|
|
307
|
+
Creates a new DOM element with the given tag name and optional creation options.
|
|
308
|
+
|
|
309
|
+
* **Parameters**:
|
|
310
|
+
|
|
311
|
+
* `tagName` *(string)* — The tag name of the element to create (e.g., `'div'`, `'span'`).
|
|
312
|
+
* `ops` *(ElementCreationOptions)* — *(optional)* Options for advanced element creation.
|
|
313
|
+
* **Returns**: `TinyHtml` — A `TinyHtml` instance wrapping the newly created element.
|
|
314
|
+
* **Throws**:
|
|
315
|
+
|
|
316
|
+
* `TypeError` — If `tagName` is not a string.
|
|
317
|
+
* `TypeError` — If `ops` is defined but not an object.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
### `TinyHtml.createTextNode(value)`
|
|
322
|
+
|
|
323
|
+
Creates a new `TinyHtml` instance that wraps a DOM `TextNode`.
|
|
324
|
+
|
|
325
|
+
This method is useful when you want to insert raw text content into the DOM without it being interpreted as HTML. The returned instance behaves like any other `TinyHtml` element and can be appended or manipulated as needed.
|
|
326
|
+
|
|
327
|
+
* **Parameters**:
|
|
328
|
+
|
|
329
|
+
* `value` *(string)* — The plain text content to be wrapped in a `TextNode`.
|
|
330
|
+
|
|
331
|
+
* **Returns**: `TinyHtml` — A `TinyHtml` instance wrapping the newly created DOM `TextNode`.
|
|
332
|
+
|
|
333
|
+
* **Throws**:
|
|
334
|
+
|
|
335
|
+
* `TypeError` — If the provided `value` is not a string.
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
### `TinyHtml.createElementFromHTML(htmlString)`
|
|
340
|
+
|
|
341
|
+
Creates an `HTMLElement` or `TextNode` from an HTML string.
|
|
342
|
+
Supports both elements and plain text.
|
|
343
|
+
|
|
344
|
+
* **Parameters**:
|
|
345
|
+
|
|
346
|
+
* `htmlString` *(string)* — The HTML string to convert.
|
|
347
|
+
|
|
348
|
+
* **Returns**: `TinyHtml` — A `TinyHtml` instance wrapping the resulting `HTMLElement` or `TextNode`.
|
|
349
|
+
|
|
350
|
+
* **Throws**:
|
|
351
|
+
|
|
352
|
+
* `Error` — If the parsed content does not produce a valid `Element` when expecting an HTML structure.
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
274
356
|
### `TinyHtml.query(selector)`
|
|
275
357
|
Finds the first element by CSS selector.
|
|
276
358
|
|
|
277
359
|
- **Parameters**:
|
|
278
360
|
- `selector` *(string)* — CSS selector
|
|
279
|
-
- **Returns**: `TinyHtml`
|
|
280
|
-
- **Throws**: If no element is found.
|
|
361
|
+
- **Returns**: `TinyHtml` or `null`
|
|
281
362
|
|
|
282
363
|
---
|
|
283
364
|
|
|
@@ -291,7 +372,9 @@ Finds all elements by CSS selector.
|
|
|
291
372
|
### `TinyHtml.getById(selector)`
|
|
292
373
|
Selects an element by ID.
|
|
293
374
|
|
|
294
|
-
- **
|
|
375
|
+
- **Parameters**:
|
|
376
|
+
- `selector` *(string)* — Id selector
|
|
377
|
+
- **Returns**: `TinyHtml` or `null`
|
|
295
378
|
|
|
296
379
|
---
|
|
297
380
|
|
|
@@ -363,6 +446,8 @@ Each method below ensures type and returns raw DOM objects:
|
|
|
363
446
|
| `_preEventTargetElem(...)` | `EventTarget` | `EventTarget` |
|
|
364
447
|
| `_preElemsAndWindow(...)` | `Element\|Window` | `ElementAndWindow[]` |
|
|
365
448
|
| `_preElemAndWindow(...)` | `Element\|Window` | `ElementAndWindow` |
|
|
449
|
+
| `_preElemsAndWinAndDoc(...)` | `Element\|Window\|Document` | `ElementAndWindow[]` |
|
|
450
|
+
| `_preElemAndWinAndDoc(...)` | `Element\|Window\|Document` | `ElementAndWindow` |
|
|
366
451
|
|
|
367
452
|
---
|
|
368
453
|
|
|
@@ -949,10 +1034,12 @@ element.empty();
|
|
|
949
1034
|
|
|
950
1035
|
---
|
|
951
1036
|
|
|
952
|
-
### 🔍 `.html()` / `TinyHtml.html(el)`
|
|
1037
|
+
### 🔍 `.html(ops?)` / `TinyHtml.html(el, ops?)`
|
|
953
1038
|
|
|
954
1039
|
Gets the `innerHTML` string of the element.
|
|
955
1040
|
|
|
1041
|
+
* `ops?`: GetHTMLOptions from native DOM.
|
|
1042
|
+
|
|
956
1043
|
```js
|
|
957
1044
|
element.html(); // → "<p>Some HTML content</p>"
|
|
958
1045
|
```
|
|
@@ -1334,6 +1421,108 @@ TinyHtml.isScrolledIntoView(element);
|
|
|
1334
1421
|
|
|
1335
1422
|
---
|
|
1336
1423
|
|
|
1424
|
+
### 🫣 `.isInContainer(container)`
|
|
1425
|
+
|
|
1426
|
+
Partially Visible in Container
|
|
1427
|
+
|
|
1428
|
+
```js
|
|
1429
|
+
element.isInContainer(container);
|
|
1430
|
+
```
|
|
1431
|
+
|
|
1432
|
+
Checks if **any part** of the element is visible **inside the scrollable container** — meaning:
|
|
1433
|
+
|
|
1434
|
+
* It **overlaps** the visible area of the container.
|
|
1435
|
+
* At least part of it is within the container’s viewport.
|
|
1436
|
+
|
|
1437
|
+
#### ✅ Use when:
|
|
1438
|
+
|
|
1439
|
+
* You want to detect if an element is **partially scrolled into view**.
|
|
1440
|
+
* Useful for triggering **lazy loading**, **animations**, or **UI changes** when something starts to appear.
|
|
1441
|
+
|
|
1442
|
+
#### 🔍 Logic:
|
|
1443
|
+
|
|
1444
|
+
* It compares the element's `getBoundingClientRect()` with the container’s.
|
|
1445
|
+
* Ensures there's **some overlap**, vertically or horizontally.
|
|
1446
|
+
|
|
1447
|
+
#### 🔁 Static version:
|
|
1448
|
+
|
|
1449
|
+
```js
|
|
1450
|
+
TinyHtml.isInContainer(element, container);
|
|
1451
|
+
```
|
|
1452
|
+
|
|
1453
|
+
---
|
|
1454
|
+
|
|
1455
|
+
### ✅ `.isFullyInContainer(container)`
|
|
1456
|
+
|
|
1457
|
+
Fully Visible in Container
|
|
1458
|
+
|
|
1459
|
+
```js
|
|
1460
|
+
element.isFullyInContainer(container);
|
|
1461
|
+
```
|
|
1462
|
+
|
|
1463
|
+
Checks if the element is **completely visible** inside the scrollable container — meaning:
|
|
1464
|
+
|
|
1465
|
+
* **Top and bottom** of the element are within the container.
|
|
1466
|
+
* **Left and right** are also inside the container’s boundaries.
|
|
1467
|
+
|
|
1468
|
+
#### ✅ Use when:
|
|
1469
|
+
|
|
1470
|
+
* You want to detect if an element is **entirely inside** its scrollable container.
|
|
1471
|
+
* Useful for triggering **lazy loading**, **animations**, or **UI changes** when something starts to appear.
|
|
1472
|
+
|
|
1473
|
+
#### 🔍 Logic:
|
|
1474
|
+
|
|
1475
|
+
* It compares the full bounding box of the element to the container's.
|
|
1476
|
+
* All four edges must be within bounds to return `true`.
|
|
1477
|
+
|
|
1478
|
+
#### 🔁 Static version:
|
|
1479
|
+
|
|
1480
|
+
```js
|
|
1481
|
+
TinyHtml.isFullyInContainer(element, container);
|
|
1482
|
+
```
|
|
1483
|
+
|
|
1484
|
+
---
|
|
1485
|
+
|
|
1486
|
+
### ✅ `.hasScroll()`
|
|
1487
|
+
|
|
1488
|
+
Detect Scrollability in Any Direction
|
|
1489
|
+
|
|
1490
|
+
```js
|
|
1491
|
+
element.hasScroll();
|
|
1492
|
+
```
|
|
1493
|
+
|
|
1494
|
+
Checks if the element has **scrollable content** in either vertical or horizontal direction.
|
|
1495
|
+
|
|
1496
|
+
Returns:
|
|
1497
|
+
|
|
1498
|
+
```js
|
|
1499
|
+
{ v: true|false, h: true|false }
|
|
1500
|
+
```
|
|
1501
|
+
|
|
1502
|
+
Where:
|
|
1503
|
+
|
|
1504
|
+
* `v` = vertical scroll present
|
|
1505
|
+
* `h` = horizontal scroll present
|
|
1506
|
+
|
|
1507
|
+
#### ✅ Use when:
|
|
1508
|
+
|
|
1509
|
+
* You want to detect **whether an element needs scrollbars**.
|
|
1510
|
+
* Useful for adjusting layout, showing scroll indicators, or enabling custom scrolling behaviors.
|
|
1511
|
+
|
|
1512
|
+
#### 🔍 Logic:
|
|
1513
|
+
|
|
1514
|
+
* It compares the element's `scrollHeight` with `clientHeight` for vertical,
|
|
1515
|
+
* And `scrollWidth` with `clientWidth` for horizontal.
|
|
1516
|
+
* If content overflows in either direction, it returns `true` for that axis.
|
|
1517
|
+
|
|
1518
|
+
#### 🔁 Static version:
|
|
1519
|
+
|
|
1520
|
+
```js
|
|
1521
|
+
TinyHtml.hasScroll(element);
|
|
1522
|
+
```
|
|
1523
|
+
|
|
1524
|
+
---
|
|
1525
|
+
|
|
1337
1526
|
## 🎨 CSS Property Aliases (`cssPropAliases`)
|
|
1338
1527
|
|
|
1339
1528
|
TinyHtml provides automatic conversion between `camelCase` and `kebab-case` style properties to simplify working with inline styles in HTML elements.
|