tiny-essentials 1.16.2 → 1.17.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/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/TinyBasicsEs.js +729 -93
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.js +656 -69
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.js +2688 -116
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.js +656 -69
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.js +6378 -0
- package/dist/v1/TinySmartScroller.min.js +1 -0
- package/dist/v1/TinyUploadClicker.js +1732 -118
- 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/TinyHtml.cjs +656 -69
- package/dist/v1/libs/TinyHtml.d.mts +440 -139
- package/dist/v1/libs/TinyHtml.mjs +591 -72
- 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/TinyHtml.md +296 -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:
|
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
|
|
|
@@ -662,6 +747,102 @@ Normalizes and converts input (elements, arrays, or strings) into appendable DOM
|
|
|
662
747
|
|
|
663
748
|
---
|
|
664
749
|
|
|
750
|
+
## 🧮 Easing Functions
|
|
751
|
+
|
|
752
|
+
### `TinyHtml.easings`
|
|
753
|
+
|
|
754
|
+
A collection of predefined easing functions used for scroll and animation calculations.
|
|
755
|
+
Each easing function takes a normalized time (`t` from 0 to 1) and returns a transformed progress value.
|
|
756
|
+
|
|
757
|
+
| Name | Description |
|
|
758
|
+
| ---------------- | ------------------------------------- |
|
|
759
|
+
| `linear` | Constant speed, no easing. |
|
|
760
|
+
| `easeInQuad` | Accelerates from zero velocity. |
|
|
761
|
+
| `easeOutQuad` | Decelerates to zero velocity. |
|
|
762
|
+
| `easeInOutQuad` | Accelerates, then decelerates. |
|
|
763
|
+
| `easeInCubic` | Starts slow, speeds up sharply. |
|
|
764
|
+
| `easeOutCubic` | Starts fast, slows down gradually. |
|
|
765
|
+
| `easeInOutCubic` | Smooth acceleration and deceleration. |
|
|
766
|
+
|
|
767
|
+
```ts
|
|
768
|
+
type Easings =
|
|
769
|
+
| 'linear'
|
|
770
|
+
| 'easeInQuad'
|
|
771
|
+
| 'easeOutQuad'
|
|
772
|
+
| 'easeInOutQuad'
|
|
773
|
+
| 'easeInCubic'
|
|
774
|
+
| 'easeOutCubic'
|
|
775
|
+
| 'easeInOutCubic';
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
```ts
|
|
779
|
+
TinyHtml.easings = {
|
|
780
|
+
linear: (t) => t,
|
|
781
|
+
easeInQuad: (t) => t * t,
|
|
782
|
+
easeOutQuad: (t) => t * (2 - t),
|
|
783
|
+
easeInOutQuad: (t) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t),
|
|
784
|
+
easeInCubic: (t) => t * t * t,
|
|
785
|
+
easeOutCubic: (t) => --t * t * t + 1,
|
|
786
|
+
easeInOutCubic: (t) => (t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1),
|
|
787
|
+
};
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
---
|
|
791
|
+
|
|
792
|
+
## 🧭 Smooth Scrolling
|
|
793
|
+
|
|
794
|
+
### `TinyHtml.scrollToXY(el, settings)`
|
|
795
|
+
|
|
796
|
+
Smoothly scrolls one or more elements (or `window`) to a target position using a custom duration and easing.
|
|
797
|
+
|
|
798
|
+
If no `duration` or invalid `easing` is provided, the scroll happens instantly.
|
|
799
|
+
|
|
800
|
+
```ts
|
|
801
|
+
TinyHtml.scrollToXY(el, {
|
|
802
|
+
targetX?: number,
|
|
803
|
+
targetY?: number,
|
|
804
|
+
duration?: number,
|
|
805
|
+
easing?: Easings,
|
|
806
|
+
});
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
| Parameter | Type | Description |
|
|
810
|
+
| -------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
811
|
+
| `el` | `TinyElementAndWindow \| TinyElementAndWindow[]` | One or more elements or the `window` to scroll. |
|
|
812
|
+
| `settings` | `Object` | Scroll configuration. |
|
|
813
|
+
| `targetX` | `number` *(optional)* | Final horizontal scroll position. |
|
|
814
|
+
| `targetY` | `number` *(optional)* | Final vertical scroll position. |
|
|
815
|
+
| `duration` | `number` *(optional)* | Duration of the scroll animation in milliseconds. |
|
|
816
|
+
| `easing` | `Easings` *(optional)* | Name of easing function to control animation curve. |
|
|
817
|
+
| `onAnimation` | `OnScrollAnimation` *(optional)* | Optional callback invoked on each animation frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag. |
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
## ⚙️ Internal Scroll Mechanism
|
|
822
|
+
|
|
823
|
+
When called, `scrollToXY()` performs:
|
|
824
|
+
|
|
825
|
+
1. **Start Position Detection** – Gets current scroll positions.
|
|
826
|
+
2. **Delta Calculation** – Calculates the distance to scroll.
|
|
827
|
+
3. **Easing Evaluation** – Determines the easing curve to use.
|
|
828
|
+
4. **Scroll Loop** – Uses `requestAnimationFrame` to animate over time.
|
|
829
|
+
5. **Instant Scroll Fallback** – If no easing/duration is defined, scrolls instantly.
|
|
830
|
+
|
|
831
|
+
```ts
|
|
832
|
+
function executeScroll(elem, newX, newY) {
|
|
833
|
+
if (elem instanceof Window) {
|
|
834
|
+
window.scrollTo(newX, newY);
|
|
835
|
+
} else if (elem.nodeType === 9) {
|
|
836
|
+
elem.defaultView.scrollTo(newX, newY); // For documents
|
|
837
|
+
} else {
|
|
838
|
+
if (elem.scrollLeft !== newX) elem.scrollLeft = newX;
|
|
839
|
+
if (elem.scrollTop !== newY) elem.scrollTop = newY;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
---
|
|
845
|
+
|
|
665
846
|
## 📏 Dimensions (Size API)
|
|
666
847
|
|
|
667
848
|
TinyHtml provides methods to **read** and **set** an element's dimensions, similar to jQuery’s width/height API, with support for box models: `content`, `padding`, `border`, and `margin`.
|
|
@@ -738,6 +919,9 @@ This API set focuses on **measuring element offsets**, **scroll positions**, and
|
|
|
738
919
|
|
|
739
920
|
### 📍 Element Positioning
|
|
740
921
|
|
|
922
|
+
#### `.animate(keyframes, ops?)` / `TinyHtml.animate(el, keyframes, ops?)`
|
|
923
|
+
Applies an animation to one or more TinyElement instances using the Web Animations API.
|
|
924
|
+
|
|
741
925
|
#### `.offset()` / `TinyHtml.offset(el)`
|
|
742
926
|
Returns the coordinates `{ top, left }` of the element **relative to the document**.
|
|
743
927
|
|
|
@@ -949,10 +1133,12 @@ element.empty();
|
|
|
949
1133
|
|
|
950
1134
|
---
|
|
951
1135
|
|
|
952
|
-
### 🔍 `.html()` / `TinyHtml.html(el)`
|
|
1136
|
+
### 🔍 `.html(ops?)` / `TinyHtml.html(el, ops?)`
|
|
953
1137
|
|
|
954
1138
|
Gets the `innerHTML` string of the element.
|
|
955
1139
|
|
|
1140
|
+
* `ops?`: GetHTMLOptions from native DOM.
|
|
1141
|
+
|
|
956
1142
|
```js
|
|
957
1143
|
element.html(); // → "<p>Some HTML content</p>"
|
|
958
1144
|
```
|
|
@@ -1334,6 +1520,108 @@ TinyHtml.isScrolledIntoView(element);
|
|
|
1334
1520
|
|
|
1335
1521
|
---
|
|
1336
1522
|
|
|
1523
|
+
### 🫣 `.isInContainer(container)`
|
|
1524
|
+
|
|
1525
|
+
Partially Visible in Container
|
|
1526
|
+
|
|
1527
|
+
```js
|
|
1528
|
+
element.isInContainer(container);
|
|
1529
|
+
```
|
|
1530
|
+
|
|
1531
|
+
Checks if **any part** of the element is visible **inside the scrollable container** — meaning:
|
|
1532
|
+
|
|
1533
|
+
* It **overlaps** the visible area of the container.
|
|
1534
|
+
* At least part of it is within the container’s viewport.
|
|
1535
|
+
|
|
1536
|
+
#### ✅ Use when:
|
|
1537
|
+
|
|
1538
|
+
* You want to detect if an element is **partially scrolled into view**.
|
|
1539
|
+
* Useful for triggering **lazy loading**, **animations**, or **UI changes** when something starts to appear.
|
|
1540
|
+
|
|
1541
|
+
#### 🔍 Logic:
|
|
1542
|
+
|
|
1543
|
+
* It compares the element's `getBoundingClientRect()` with the container’s.
|
|
1544
|
+
* Ensures there's **some overlap**, vertically or horizontally.
|
|
1545
|
+
|
|
1546
|
+
#### 🔁 Static version:
|
|
1547
|
+
|
|
1548
|
+
```js
|
|
1549
|
+
TinyHtml.isInContainer(element, container);
|
|
1550
|
+
```
|
|
1551
|
+
|
|
1552
|
+
---
|
|
1553
|
+
|
|
1554
|
+
### ✅ `.isFullyInContainer(container)`
|
|
1555
|
+
|
|
1556
|
+
Fully Visible in Container
|
|
1557
|
+
|
|
1558
|
+
```js
|
|
1559
|
+
element.isFullyInContainer(container);
|
|
1560
|
+
```
|
|
1561
|
+
|
|
1562
|
+
Checks if the element is **completely visible** inside the scrollable container — meaning:
|
|
1563
|
+
|
|
1564
|
+
* **Top and bottom** of the element are within the container.
|
|
1565
|
+
* **Left and right** are also inside the container’s boundaries.
|
|
1566
|
+
|
|
1567
|
+
#### ✅ Use when:
|
|
1568
|
+
|
|
1569
|
+
* You want to detect if an element is **entirely inside** its scrollable container.
|
|
1570
|
+
* Useful for triggering **lazy loading**, **animations**, or **UI changes** when something starts to appear.
|
|
1571
|
+
|
|
1572
|
+
#### 🔍 Logic:
|
|
1573
|
+
|
|
1574
|
+
* It compares the full bounding box of the element to the container's.
|
|
1575
|
+
* All four edges must be within bounds to return `true`.
|
|
1576
|
+
|
|
1577
|
+
#### 🔁 Static version:
|
|
1578
|
+
|
|
1579
|
+
```js
|
|
1580
|
+
TinyHtml.isFullyInContainer(element, container);
|
|
1581
|
+
```
|
|
1582
|
+
|
|
1583
|
+
---
|
|
1584
|
+
|
|
1585
|
+
### ✅ `.hasScroll()`
|
|
1586
|
+
|
|
1587
|
+
Detect Scrollability in Any Direction
|
|
1588
|
+
|
|
1589
|
+
```js
|
|
1590
|
+
element.hasScroll();
|
|
1591
|
+
```
|
|
1592
|
+
|
|
1593
|
+
Checks if the element has **scrollable content** in either vertical or horizontal direction.
|
|
1594
|
+
|
|
1595
|
+
Returns:
|
|
1596
|
+
|
|
1597
|
+
```js
|
|
1598
|
+
{ v: true|false, h: true|false }
|
|
1599
|
+
```
|
|
1600
|
+
|
|
1601
|
+
Where:
|
|
1602
|
+
|
|
1603
|
+
* `v` = vertical scroll present
|
|
1604
|
+
* `h` = horizontal scroll present
|
|
1605
|
+
|
|
1606
|
+
#### ✅ Use when:
|
|
1607
|
+
|
|
1608
|
+
* You want to detect **whether an element needs scrollbars**.
|
|
1609
|
+
* Useful for adjusting layout, showing scroll indicators, or enabling custom scrolling behaviors.
|
|
1610
|
+
|
|
1611
|
+
#### 🔍 Logic:
|
|
1612
|
+
|
|
1613
|
+
* It compares the element's `scrollHeight` with `clientHeight` for vertical,
|
|
1614
|
+
* And `scrollWidth` with `clientWidth` for horizontal.
|
|
1615
|
+
* If content overflows in either direction, it returns `true` for that axis.
|
|
1616
|
+
|
|
1617
|
+
#### 🔁 Static version:
|
|
1618
|
+
|
|
1619
|
+
```js
|
|
1620
|
+
TinyHtml.hasScroll(element);
|
|
1621
|
+
```
|
|
1622
|
+
|
|
1623
|
+
---
|
|
1624
|
+
|
|
1337
1625
|
## 🎨 CSS Property Aliases (`cssPropAliases`)
|
|
1338
1626
|
|
|
1339
1627
|
TinyHtml provides automatic conversion between `camelCase` and `kebab-case` style properties to simplify working with inline styles in HTML elements.
|