tiny-essentials 1.16.0 โ 1.16.2
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/TinyAfterScrollWatcher.js +219 -0
- package/dist/v1/TinyAfterScrollWatcher.min.js +1 -0
- package/dist/v1/TinyBasicsEs.js +488 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.js +488 -0
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.js +670 -0
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.js +488 -0
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinyUploadClicker.js +489 -0
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/build/TinyAfterScrollWatcher.cjs +7 -0
- package/dist/v1/build/TinyAfterScrollWatcher.d.mts +3 -0
- package/dist/v1/build/TinyAfterScrollWatcher.mjs +2 -0
- package/dist/v1/index.cjs +2 -0
- package/dist/v1/index.d.mts +2 -1
- package/dist/v1/index.mjs +2 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.cjs +180 -0
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +89 -0
- package/dist/v1/libs/TinyAfterScrollWatcher.mjs +164 -0
- package/dist/v1/libs/TinyHtml.cjs +488 -0
- package/dist/v1/libs/TinyHtml.d.mts +150 -0
- package/dist/v1/libs/TinyHtml.mjs +469 -0
- package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
- package/docs/v1/README.md +10 -10
- package/docs/v1/libs/TinyAfterScrollWatcher.md +231 -0
- package/docs/v1/libs/TinyHtml.md +325 -0
- package/package.json +1 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# ๐ TinyAfterScrollWatcher
|
|
2
|
+
|
|
3
|
+
A minimalistic scroll watcher that queues and executes functions **after scrolling has stopped** on a given element or the window.
|
|
4
|
+
Perfect for optimizing logic that should only run **after** the user has finished scrolling.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ๐ Features
|
|
9
|
+
|
|
10
|
+
* โ
Works on any scrollable element or the window
|
|
11
|
+
* โฑ๏ธ Customizable "inactivity timeout" (default: `100ms`)
|
|
12
|
+
* ๐ง Executes queued callbacks after scroll ends
|
|
13
|
+
* ๐งท Add/remove scroll listeners easily (`onScroll` / `offScroll`)
|
|
14
|
+
* ๐ Execute logic right before after-scroll queue (`onStop`)
|
|
15
|
+
* ๐งน Cleanly destroy the instance when no longer needed
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## ๐ฆ Import
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import TinyAfterScrollWatcher from './TinyAfterScrollWatcher.mjs';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## ๐งช Example
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
const watcher = new TinyAfterScrollWatcher(window);
|
|
31
|
+
|
|
32
|
+
// Optional: set a custom delay (in ms)
|
|
33
|
+
watcher.inactivityTime = 300;
|
|
34
|
+
|
|
35
|
+
// Add a function to run after scroll has stopped
|
|
36
|
+
watcher.doAfterScroll(() => {
|
|
37
|
+
console.log('Scroll has stopped for 300ms!');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Add a function to run immediately when scroll stops
|
|
41
|
+
watcher.onStop(() => {
|
|
42
|
+
console.log('User just stopped scrolling!');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Add a custom scroll listener
|
|
46
|
+
const myScrollHandler = () => console.log('Scrolling...');
|
|
47
|
+
watcher.onScroll(myScrollHandler);
|
|
48
|
+
|
|
49
|
+
// Remove it later
|
|
50
|
+
watcher.offScroll(myScrollHandler);
|
|
51
|
+
|
|
52
|
+
// Also remove onStop listener
|
|
53
|
+
watcher.offStop(myStopFunction);
|
|
54
|
+
|
|
55
|
+
// Fully destroy the watcher
|
|
56
|
+
watcher.destroy();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## ๐ง Class: `TinyAfterScrollWatcher`
|
|
62
|
+
|
|
63
|
+
### ๐ง Constructor
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
new TinyAfterScrollWatcher(scrollTarget?: Element | Window, inactivityTime?: number)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Parameters:
|
|
70
|
+
|
|
71
|
+
| Name | Type | Default | Description |
|
|
72
|
+
| ---------------- | ------------------- | -------- | ---------------------------------------------------------------------- |
|
|
73
|
+
| `scrollTarget` | `Element \| Window` | `window` | The scrollable element to watch. Can also be the global `window`. |
|
|
74
|
+
| `inactivityTime` | `number` | `100` | Milliseconds to wait after the last scroll before executing the queue. |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### โฒ๏ธ Property: `inactivityTime`
|
|
79
|
+
|
|
80
|
+
* **Type:** `number`
|
|
81
|
+
* **Getter/Setter**
|
|
82
|
+
|
|
83
|
+
Defines how many milliseconds to wait after scroll stops before executing the queue.
|
|
84
|
+
|
|
85
|
+
#### Example:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
watcher.inactivityTime = 500;
|
|
89
|
+
console.log(watcher.inactivityTime); // 500
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Throws:
|
|
93
|
+
|
|
94
|
+
* `TypeError` if the value is not a finite positive number.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### ๐งฉ Method: `doAfterScroll(fn)`
|
|
99
|
+
|
|
100
|
+
Adds a function to the queue that runs once scroll has stopped for the configured delay.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
doAfterScroll(fn: FnData): void
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### Parameters:
|
|
107
|
+
|
|
108
|
+
| Name | Type | Description |
|
|
109
|
+
| ---- | -------- | ------------------------------------ |
|
|
110
|
+
| `fn` | `FnData` | Function to run after scrolling ends |
|
|
111
|
+
|
|
112
|
+
#### Throws:
|
|
113
|
+
|
|
114
|
+
* `TypeError` if the argument is not a function.
|
|
115
|
+
|
|
116
|
+
---
|
|
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
|
+
|
|
158
|
+
### ๐งท Method: `onScroll(fn)`
|
|
159
|
+
|
|
160
|
+
Registers a custom scroll listener on the tracked element.
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
onScroll(fn: OnScrollFunc): void
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
#### Parameters:
|
|
167
|
+
|
|
168
|
+
| Name | Type | Description |
|
|
169
|
+
| ---- | -------------- | --------------------------------------- |
|
|
170
|
+
| `fn` | `OnScrollFunc` | The listener function for scroll events |
|
|
171
|
+
|
|
172
|
+
#### Throws:
|
|
173
|
+
|
|
174
|
+
* `TypeError` if the argument is not a function.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### ๐๏ธ Method: `offScroll(fn)`
|
|
179
|
+
|
|
180
|
+
Removes a previously registered scroll listener.
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
offScroll(fn: OnScrollFunc): void
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### Parameters:
|
|
187
|
+
|
|
188
|
+
| Name | Type | Description |
|
|
189
|
+
| ---- | -------------- | ----------------------------- |
|
|
190
|
+
| `fn` | `OnScrollFunc` | The scroll listener to remove |
|
|
191
|
+
|
|
192
|
+
#### Throws:
|
|
193
|
+
|
|
194
|
+
* `TypeError` if the argument is not a function.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
### ๐ฃ Method: `destroy()`
|
|
199
|
+
|
|
200
|
+
Cleans up all internal and external listeners.
|
|
201
|
+
Once destroyed, the instance stops functioning and cannot be reused.
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
destroy(): void
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## ๐งพ Typedefs
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
/**
|
|
213
|
+
* A function with no parameters and no return value.
|
|
214
|
+
*/
|
|
215
|
+
type FnData = () => void;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* A function that handles a scroll event.
|
|
219
|
+
* It receives a standard `Event` object when a scroll occurs.
|
|
220
|
+
*/
|
|
221
|
+
type OnScrollFunc = (ev: Event) => void;
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## ๐ Notes
|
|
227
|
+
|
|
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
|
@@ -1331,3 +1331,328 @@ Checks if the element is **fully inside** the viewport โ meaning:
|
|
|
1331
1331
|
```js
|
|
1332
1332
|
TinyHtml.isScrolledIntoView(element);
|
|
1333
1333
|
```
|
|
1334
|
+
|
|
1335
|
+
---
|
|
1336
|
+
|
|
1337
|
+
## ๐จ CSS Property Aliases (`cssPropAliases`)
|
|
1338
|
+
|
|
1339
|
+
TinyHtml provides automatic conversion between `camelCase` and `kebab-case` style properties to simplify working with inline styles in HTML elements.
|
|
1340
|
+
|
|
1341
|
+
This is useful for working with both JavaScript style names and the raw `style=""` attribute.
|
|
1342
|
+
|
|
1343
|
+
### ๐ Alias Mapping
|
|
1344
|
+
|
|
1345
|
+
The object `cssPropAliases` maps JavaScript-style property names (`camelCase`) to their CSS equivalents (`kebab-case`), for example:
|
|
1346
|
+
|
|
1347
|
+
```js
|
|
1348
|
+
TinyHtml.cssPropAliases.backgroundColor; // "background-color"
|
|
1349
|
+
```
|
|
1350
|
+
|
|
1351
|
+
โ ๏ธ Do not modify the internal `#cssPropAliases` object directly. Instead, use the `TinyHtml.cssPropAliases` proxy.
|
|
1352
|
+
|
|
1353
|
+
### โ๏ธ Adding a New Alias
|
|
1354
|
+
|
|
1355
|
+
To add a new alias and automatically generate the reverse mapping:
|
|
1356
|
+
|
|
1357
|
+
```js
|
|
1358
|
+
TinyHtml.cssPropAliases.tinyPudding = 'tiny-pudding';
|
|
1359
|
+
```
|
|
1360
|
+
|
|
1361
|
+
This will automatically make this available:
|
|
1362
|
+
|
|
1363
|
+
```js
|
|
1364
|
+
TinyHtml.cssPropRevAliases['tiny-pudding']; // "tinyPudding"
|
|
1365
|
+
```
|
|
1366
|
+
|
|
1367
|
+
---
|
|
1368
|
+
|
|
1369
|
+
## โ๏ธ Utility Functions
|
|
1370
|
+
|
|
1371
|
+
### ๐ก `TinyHtml.toStyleKc(str)`
|
|
1372
|
+
|
|
1373
|
+
Converts a camelCase property to kebab-case if it exists in the alias list.
|
|
1374
|
+
|
|
1375
|
+
```js
|
|
1376
|
+
TinyHtml.toStyleKc('marginLeft'); // "margin-left"
|
|
1377
|
+
```
|
|
1378
|
+
|
|
1379
|
+
### ๐ก `TinyHtml.toStyleCc(str)`
|
|
1380
|
+
|
|
1381
|
+
Converts a kebab-case property to camelCase if it exists in the reverse alias list.
|
|
1382
|
+
|
|
1383
|
+
```js
|
|
1384
|
+
TinyHtml.toStyleCc('font-weight'); // "fontWeight"
|
|
1385
|
+
```
|
|
1386
|
+
|
|
1387
|
+
---
|
|
1388
|
+
|
|
1389
|
+
## ๐งฉ Style Methods
|
|
1390
|
+
|
|
1391
|
+
### ๐ฏ `TinyHtml.setStyle(el, prop, value)`
|
|
1392
|
+
|
|
1393
|
+
Sets one or more inline CSS properties on an element or a list of elements.
|
|
1394
|
+
|
|
1395
|
+
```js
|
|
1396
|
+
TinyHtml.setStyle(element, 'backgroundColor', 'blue');
|
|
1397
|
+
|
|
1398
|
+
TinyHtml.setStyle(element, {
|
|
1399
|
+
fontSize: '14px',
|
|
1400
|
+
color: 'white',
|
|
1401
|
+
});
|
|
1402
|
+
```
|
|
1403
|
+
|
|
1404
|
+
---
|
|
1405
|
+
|
|
1406
|
+
### ๐ `TinyHtml.getStyle(el, prop)`
|
|
1407
|
+
|
|
1408
|
+
Returns the value of an inline style property (not computed).
|
|
1409
|
+
|
|
1410
|
+
```js
|
|
1411
|
+
TinyHtml.getStyle(element, 'backgroundColor'); // "blue"
|
|
1412
|
+
```
|
|
1413
|
+
|
|
1414
|
+
---
|
|
1415
|
+
|
|
1416
|
+
### ๐งพ `TinyHtml.style(el, settings = {})`
|
|
1417
|
+
|
|
1418
|
+
Returns all inline styles defined directly on the element (`style` attribute), as an object.
|
|
1419
|
+
|
|
1420
|
+
You can customize the output by passing an optional settings object:
|
|
1421
|
+
|
|
1422
|
+
* `camelCase` (`boolean`, default `false`) โ If `true`, property names will be returned in camelCase format.
|
|
1423
|
+
* `rawAttr` (`boolean`, default `false`) โ If `true`, the raw `style` attribute string will be parsed manually instead of using the element's `style` object.
|
|
1424
|
+
|
|
1425
|
+
#### โ
Examples
|
|
1426
|
+
|
|
1427
|
+
```js
|
|
1428
|
+
TinyHtml.style(element, { rawAttr: true, camelCase: false });
|
|
1429
|
+
// {
|
|
1430
|
+
// "background-color": "tomato",
|
|
1431
|
+
// "border-radius": "10px"
|
|
1432
|
+
// }
|
|
1433
|
+
|
|
1434
|
+
TinyHtml.style(element, { rawAttr: true, camelCase: true });
|
|
1435
|
+
// {
|
|
1436
|
+
// backgroundColor: "tomato",
|
|
1437
|
+
// borderRadius: "10px"
|
|
1438
|
+
// }
|
|
1439
|
+
|
|
1440
|
+
TinyHtml.style(element, { rawAttr: false, camelCase: true });
|
|
1441
|
+
// {
|
|
1442
|
+
// "backgroundColor":"tomato",
|
|
1443
|
+
// "borderTopLeftRadius":"10px",
|
|
1444
|
+
// "borderTopRightRadius":"10px",
|
|
1445
|
+
// "borderBottomRightRadius":"10px",
|
|
1446
|
+
// "borderBottomLeftRadius":"10px",
|
|
1447
|
+
// "borderTopStyle":"dashed",
|
|
1448
|
+
// "borderRightStyle":"dashed",
|
|
1449
|
+
// "borderBottomStyle":"dashed",
|
|
1450
|
+
// "borderLeftStyle":"dashed"
|
|
1451
|
+
// }
|
|
1452
|
+
```
|
|
1453
|
+
|
|
1454
|
+
---
|
|
1455
|
+
|
|
1456
|
+
### โ `TinyHtml.removeStyle(el, prop)`
|
|
1457
|
+
|
|
1458
|
+
Removes one or more properties from an elementโs inline styles.
|
|
1459
|
+
|
|
1460
|
+
```js
|
|
1461
|
+
TinyHtml.removeStyle(element, 'color');
|
|
1462
|
+
|
|
1463
|
+
TinyHtml.removeStyle(element, ['fontSize', 'padding']);
|
|
1464
|
+
```
|
|
1465
|
+
|
|
1466
|
+
---
|
|
1467
|
+
|
|
1468
|
+
### ๐ `TinyHtml.toggleStyle(el, prop, val1, val2)`
|
|
1469
|
+
|
|
1470
|
+
Toggles a CSS inline property between two values.
|
|
1471
|
+
|
|
1472
|
+
```js
|
|
1473
|
+
TinyHtml.toggleStyle(element, 'backgroundColor', 'blue', 'red');
|
|
1474
|
+
```
|
|
1475
|
+
|
|
1476
|
+
---
|
|
1477
|
+
|
|
1478
|
+
### ๐งผ `TinyHtml.clearStyle(el)`
|
|
1479
|
+
|
|
1480
|
+
Removes all inline styles (`style=""`) from the element(s).
|
|
1481
|
+
|
|
1482
|
+
```js
|
|
1483
|
+
TinyHtml.clearStyle(element);
|
|
1484
|
+
```
|
|
1485
|
+
|
|
1486
|
+
---
|
|
1487
|
+
|
|
1488
|
+
## ๐งช Reading Computed Styles
|
|
1489
|
+
|
|
1490
|
+
TinyHtml provides multiple utilities for reading CSS styles from elements, both individually and in groups, using computed values (via `window.getComputedStyle`).
|
|
1491
|
+
|
|
1492
|
+
---
|
|
1493
|
+
|
|
1494
|
+
### ๐งฌ `TinyHtml.css(el)` / `el.css()`
|
|
1495
|
+
|
|
1496
|
+
Returns the full computed style object for a given element.
|
|
1497
|
+
|
|
1498
|
+
```js
|
|
1499
|
+
const style = TinyHtml.css(element);
|
|
1500
|
+
|
|
1501
|
+
// or using instance:
|
|
1502
|
+
const style = myTinyElem.css();
|
|
1503
|
+
```
|
|
1504
|
+
|
|
1505
|
+
**Returns:**
|
|
1506
|
+
`CSSStyleDeclaration` โ all computed styles from the browser.
|
|
1507
|
+
|
|
1508
|
+
---
|
|
1509
|
+
|
|
1510
|
+
### ๐ `TinyHtml.cssString(el, prop)` / `el.cssString(prop)`
|
|
1511
|
+
|
|
1512
|
+
Returns a specific **computed CSS value as a string**.
|
|
1513
|
+
|
|
1514
|
+
```js
|
|
1515
|
+
myTinyElem.cssString('marginTop'); // "10px"
|
|
1516
|
+
```
|
|
1517
|
+
|
|
1518
|
+
**Returns:**
|
|
1519
|
+
`string | null` โ The computed value of the property, or `null` if invalid.
|
|
1520
|
+
|
|
1521
|
+
---
|
|
1522
|
+
|
|
1523
|
+
### ๐ `TinyHtml.cssList(el, props[])` / `el.cssList(props[])`
|
|
1524
|
+
|
|
1525
|
+
Returns a **subset of computed styles** based on a list of property names.
|
|
1526
|
+
|
|
1527
|
+
```js
|
|
1528
|
+
TinyHtml.cssList(element, ['width', 'height']);
|
|
1529
|
+
// { width: "120px", height: "40px" }
|
|
1530
|
+
```
|
|
1531
|
+
|
|
1532
|
+
**Returns:**
|
|
1533
|
+
`Partial<CSSStyleDeclaration>` โ only the requested properties.
|
|
1534
|
+
|
|
1535
|
+
---
|
|
1536
|
+
|
|
1537
|
+
### ๐ข `TinyHtml.cssFloat(el, prop)` / `el.cssFloat(prop)`
|
|
1538
|
+
|
|
1539
|
+
Returns the **computed value parsed as a float number**.
|
|
1540
|
+
|
|
1541
|
+
```js
|
|
1542
|
+
myTinyElem.cssFloat('width'); // 120
|
|
1543
|
+
```
|
|
1544
|
+
|
|
1545
|
+
This is useful when working with dimensions or numeric spacing.
|
|
1546
|
+
|
|
1547
|
+
**Returns:**
|
|
1548
|
+
`number` โ A parsed float, or `0` if invalid.
|
|
1549
|
+
|
|
1550
|
+
---
|
|
1551
|
+
|
|
1552
|
+
### ๐ข๐ข `TinyHtml.cssFloats(el, props[])` / `el.cssFloats(props[])`
|
|
1553
|
+
|
|
1554
|
+
Gets multiple computed CSS float values at once.
|
|
1555
|
+
|
|
1556
|
+
```js
|
|
1557
|
+
myTinyElem.cssFloats(['paddingTop', 'paddingBottom']);
|
|
1558
|
+
// { paddingTop: 10, paddingBottom: 5 }
|
|
1559
|
+
```
|
|
1560
|
+
|
|
1561
|
+
**Returns:**
|
|
1562
|
+
`Record<string, number>` โ A mapping of property names to their float values.
|
|
1563
|
+
|
|
1564
|
+
---
|
|
1565
|
+
|
|
1566
|
+
## ๐ฑ๏ธ Focus & Blur
|
|
1567
|
+
|
|
1568
|
+
TinyHtml provides utility methods to programmatically focus or blur HTML elements.
|
|
1569
|
+
|
|
1570
|
+
### โจ `TinyHtml.focus(el)` / `el.focus()`
|
|
1571
|
+
|
|
1572
|
+
Focuses the specified element.
|
|
1573
|
+
|
|
1574
|
+
```js
|
|
1575
|
+
TinyHtml.focus(element);
|
|
1576
|
+
// or
|
|
1577
|
+
tinyElem.focus();
|
|
1578
|
+
```
|
|
1579
|
+
|
|
1580
|
+
---
|
|
1581
|
+
|
|
1582
|
+
### ๐ซ๏ธ `TinyHtml.blur(el)` / `el.blur()`
|
|
1583
|
+
|
|
1584
|
+
Removes focus from the specified element.
|
|
1585
|
+
|
|
1586
|
+
```js
|
|
1587
|
+
TinyHtml.blur(element);
|
|
1588
|
+
// or
|
|
1589
|
+
tinyElem.blur();
|
|
1590
|
+
```
|
|
1591
|
+
|
|
1592
|
+
---
|
|
1593
|
+
|
|
1594
|
+
## ๐ Window Scroll & Viewport Helpers
|
|
1595
|
+
|
|
1596
|
+
These methods let you control and query scroll positions and viewport size with simple, readable functions.
|
|
1597
|
+
|
|
1598
|
+
---
|
|
1599
|
+
|
|
1600
|
+
### ๐ฝ `TinyHtml.setWinScrollTop(value)`
|
|
1601
|
+
|
|
1602
|
+
Scrolls the window vertically to the given pixel value.
|
|
1603
|
+
|
|
1604
|
+
```js
|
|
1605
|
+
TinyHtml.setWinScrollTop(500);
|
|
1606
|
+
```
|
|
1607
|
+
|
|
1608
|
+
---
|
|
1609
|
+
|
|
1610
|
+
### โฌ
๏ธ `TinyHtml.setWinScrollLeft(value)`
|
|
1611
|
+
|
|
1612
|
+
Scrolls the window horizontally to the given pixel value.
|
|
1613
|
+
|
|
1614
|
+
```js
|
|
1615
|
+
TinyHtml.setWinScrollLeft(200);
|
|
1616
|
+
```
|
|
1617
|
+
|
|
1618
|
+
---
|
|
1619
|
+
|
|
1620
|
+
### ๐ `TinyHtml.winScrollTop()`
|
|
1621
|
+
|
|
1622
|
+
Returns the current vertical scroll position.
|
|
1623
|
+
|
|
1624
|
+
```js
|
|
1625
|
+
const y = TinyHtml.winScrollTop(); // e.g., 512
|
|
1626
|
+
```
|
|
1627
|
+
|
|
1628
|
+
---
|
|
1629
|
+
|
|
1630
|
+
### ๐ `TinyHtml.winScrollLeft()`
|
|
1631
|
+
|
|
1632
|
+
Returns the current horizontal scroll position.
|
|
1633
|
+
|
|
1634
|
+
```js
|
|
1635
|
+
const x = TinyHtml.winScrollLeft(); // e.g., 100
|
|
1636
|
+
```
|
|
1637
|
+
|
|
1638
|
+
---
|
|
1639
|
+
|
|
1640
|
+
### ๐ช `TinyHtml.winInnerHeight()`
|
|
1641
|
+
|
|
1642
|
+
Returns the height of the visible viewport in pixels.
|
|
1643
|
+
|
|
1644
|
+
```js
|
|
1645
|
+
const height = TinyHtml.winInnerHeight(); // e.g., 1080
|
|
1646
|
+
```
|
|
1647
|
+
|
|
1648
|
+
---
|
|
1649
|
+
|
|
1650
|
+
### ๐ช `TinyHtml.winInnerWidth()`
|
|
1651
|
+
|
|
1652
|
+
Returns the width of the visible viewport in pixels.
|
|
1653
|
+
|
|
1654
|
+
```js
|
|
1655
|
+
const width = TinyHtml.winInnerWidth(); // e.g., 2560
|
|
1656
|
+
```
|
|
1657
|
+
|
|
1658
|
+
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.2",
|
|
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",
|