tiny-essentials 1.15.0 → 1.16.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.
Files changed (47) hide show
  1. package/dist/v1/TinyAfterScrollWatcher.js +196 -0
  2. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -0
  3. package/dist/v1/TinyBasicsEs.js +5058 -745
  4. package/dist/v1/TinyBasicsEs.min.js +1 -1
  5. package/dist/v1/TinyDragger.js +4874 -546
  6. package/dist/v1/TinyDragger.min.js +1 -1
  7. package/dist/v1/TinyEssentials.js +5299 -750
  8. package/dist/v1/TinyEssentials.min.js +1 -1
  9. package/dist/v1/TinyHtml.js +4815 -0
  10. package/dist/v1/TinyHtml.min.js +1 -0
  11. package/dist/v1/TinyUploadClicker.js +5093 -298
  12. package/dist/v1/TinyUploadClicker.min.js +1 -1
  13. package/dist/v1/basics/html.cjs +5 -187
  14. package/dist/v1/basics/html.d.mts +2 -53
  15. package/dist/v1/basics/html.mjs +5 -161
  16. package/dist/v1/basics/html_deprecated.cjs +124 -0
  17. package/dist/v1/basics/html_deprecated.d.mts +40 -0
  18. package/dist/v1/basics/html_deprecated.mjs +97 -0
  19. package/dist/v1/basics/index.cjs +8 -7
  20. package/dist/v1/basics/index.d.mts +7 -7
  21. package/dist/v1/basics/index.mjs +2 -1
  22. package/dist/v1/build/TinyAfterScrollWatcher.cjs +7 -0
  23. package/dist/v1/build/TinyAfterScrollWatcher.d.mts +3 -0
  24. package/dist/v1/build/TinyAfterScrollWatcher.mjs +2 -0
  25. package/dist/v1/build/TinyHtml.cjs +7 -0
  26. package/dist/v1/build/TinyHtml.d.mts +3 -0
  27. package/dist/v1/build/TinyHtml.mjs +2 -0
  28. package/dist/v1/index.cjs +12 -7
  29. package/dist/v1/index.d.mts +10 -8
  30. package/dist/v1/index.mjs +5 -2
  31. package/dist/v1/libs/TinyAfterScrollWatcher.cjs +157 -0
  32. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +86 -0
  33. package/dist/v1/libs/TinyAfterScrollWatcher.mjs +138 -0
  34. package/dist/v1/libs/TinyDragger.cjs +91 -16
  35. package/dist/v1/libs/TinyDragger.d.mts +78 -2
  36. package/dist/v1/libs/TinyDragger.mjs +93 -17
  37. package/dist/v1/libs/TinyHtml.cjs +4347 -0
  38. package/dist/v1/libs/TinyHtml.d.mts +2301 -0
  39. package/dist/v1/libs/TinyHtml.mjs +3926 -0
  40. package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
  41. package/docs/v1/README.md +11 -10
  42. package/docs/v1/basics/html.md +0 -130
  43. package/docs/v1/basics/html_deprecated.md +127 -0
  44. package/docs/v1/libs/TinyAfterScrollWatcher.md +181 -0
  45. package/docs/v1/libs/TinyDragger.md +45 -15
  46. package/docs/v1/libs/TinyHtml.md +1658 -0
  47. package/package.json +4 -1
@@ -1,63 +1,5 @@
1
1
  import { isJsonObject } from './objFilter.mjs';
2
- import { areElsColliding, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, } from './collision.mjs';
3
- /**
4
- * Checks if two DOM elements are colliding on the screen.
5
- *
6
- * @param {Element} elem1 - First DOM element.
7
- * @param {Element} elem2 - Second DOM element.
8
- * @returns {boolean} - Returns true if the elements are colliding.
9
- */
10
- export function areHtmlElsColliding(elem1, elem2) {
11
- const rect1 = elem1.getBoundingClientRect();
12
- const rect2 = elem2.getBoundingClientRect();
13
- return areElsColliding(rect1, rect2);
14
- }
15
- /**
16
- * Checks if two DOM elements are colliding on the screen, and locks the collision
17
- * until the element exits through the same side it entered.
18
- *
19
- * @param {Element} elem1 - First DOM element (e.g. draggable or moving element).
20
- * @param {Element} elem2 - Second DOM element (e.g. a container or boundary element).
21
- * @param {'top'|'bottom'|'left'|'right'} lockDirection - Direction that must be respected to unlock the collision.
22
- * @param {WeakMap<Element, string>} stateMap - A shared WeakMap to track persistent entry direction per element.
23
- * @returns {boolean} True if collision is still active.
24
- */
25
- export function areHtmlElsCollidingWithLock(elem1, elem2, lockDirection, stateMap) {
26
- const rect1 = elem1.getBoundingClientRect();
27
- const rect2 = elem2.getBoundingClientRect();
28
- const isColliding = areElsColliding(rect1, rect2);
29
- if (isColliding) {
30
- // Save entry direction
31
- if (!stateMap.has(elem1)) {
32
- stateMap.set(elem1, lockDirection);
33
- }
34
- return true;
35
- }
36
- // Handle unlock logic
37
- if (stateMap.has(elem1)) {
38
- const lastDirection = stateMap.get(elem1);
39
- switch (lastDirection) {
40
- case 'top':
41
- if (areElsCollTop(rect1, rect2))
42
- stateMap.delete(elem1); // exited from top
43
- break;
44
- case 'bottom':
45
- if (areElsCollBottom(rect1, rect2))
46
- stateMap.delete(elem1); // exited from bottom
47
- break;
48
- case 'left':
49
- if (areElsCollLeft(rect1, rect2))
50
- stateMap.delete(elem1); // exited from left
51
- break;
52
- case 'right':
53
- if (areElsCollRight(rect1, rect2))
54
- stateMap.delete(elem1); // exited from right
55
- break;
56
- }
57
- return stateMap.has(elem1); // still colliding (locked)
58
- }
59
- return false;
60
- }
2
+ /////////////////////////////////////////////////////////////////
61
3
  /**
62
4
  * Reads the contents of a file using the specified FileReader method.
63
5
  *
@@ -247,86 +189,14 @@ export async function fetchJson(url, { method = 'GET', body, timeout = 0, retrie
247
189
  }
248
190
  throw new Error(`Failed to fetch JSON from "${url}"${lastError ? `: ${lastError.message}` : '.'}`);
249
191
  }
250
- /**
251
- * @typedef {Object} HtmlElBoxSides
252
- * @property {number} x - Total horizontal size (left + right)
253
- * @property {number} y - Total vertical size (top + bottom)
254
- * @property {number} left
255
- * @property {number} right
256
- * @property {number} top
257
- * @property {number} bottom
258
- */
259
- /**
260
- * Returns the total border width and individual sides from `border{Side}Width` CSS properties.
261
- *
262
- * @param {Element} el - The target DOM element.
263
- * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border widths, and each side individually.
264
- */
265
- export const getHtmlElBordersWidth = (el) => {
266
- const styles = getComputedStyle(el);
267
- const left = parseFloat(styles.borderLeftWidth) || 0;
268
- const right = parseFloat(styles.borderRightWidth) || 0;
269
- const top = parseFloat(styles.borderTopWidth) || 0;
270
- const bottom = parseFloat(styles.borderBottomWidth) || 0;
271
- const x = left + right;
272
- const y = top + bottom;
273
- return { x, y, left, right, top, bottom };
274
- };
275
- /**
276
- * Returns the total border size and individual sides from `border{Side}` CSS properties.
277
- *
278
- * @param {Element} el - The target DOM element.
279
- * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border sizes, and each side individually.
280
- */
281
- export const getHtmlElBorders = (el) => {
282
- const styles = getComputedStyle(el);
283
- const left = parseFloat(styles.borderLeft) || 0;
284
- const right = parseFloat(styles.borderRight) || 0;
285
- const top = parseFloat(styles.borderTop) || 0;
286
- const bottom = parseFloat(styles.borderBottom) || 0;
287
- const x = left + right;
288
- const y = top + bottom;
289
- return { x, y, left, right, top, bottom };
290
- };
291
- /**
292
- * Returns the total margin and individual sides from `margin{Side}` CSS properties.
293
- *
294
- * @param {Element} el - The target DOM element.
295
- * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) margins, and each side individually.
296
- */
297
- export const getHtmlElMargin = (el) => {
298
- const styles = getComputedStyle(el);
299
- const left = parseFloat(styles.marginLeft) || 0;
300
- const right = parseFloat(styles.marginRight) || 0;
301
- const top = parseFloat(styles.marginTop) || 0;
302
- const bottom = parseFloat(styles.marginBottom) || 0;
303
- const x = left + right;
304
- const y = top + bottom;
305
- return { x, y, left, right, top, bottom };
306
- };
307
- /**
308
- * Returns the total padding and individual sides from `padding{Side}` CSS properties.
309
- *
310
- * @param {Element} el - The target DOM element.
311
- * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
312
- */
313
- export const getHtmlElPadding = (el) => {
314
- const styles = getComputedStyle(el);
315
- const left = parseFloat(styles.paddingLeft) || 0;
316
- const right = parseFloat(styles.paddingRight) || 0;
317
- const top = parseFloat(styles.paddingTop) || 0;
318
- const bottom = parseFloat(styles.paddingBottom) || 0;
319
- const x = left + right;
320
- const y = top + bottom;
321
- return { x, y, left, right, top, bottom };
322
- };
192
+ ///////////////////////////////////////////////////////////////////////////////
323
193
  /**
324
194
  * Installs a script that toggles CSS classes on a given element
325
195
  * based on the page's visibility or focus state, and optionally
326
196
  * triggers callbacks on visibility changes.
327
197
  *
328
198
  * @param {Object} [settings={}]
329
- * @param {HTMLElement} [settings.element=document.body] - The element to receive visibility classes.
199
+ * @param {Element} [settings.element=document.body] - The element to receive visibility classes.
330
200
  * @param {string} [settings.hiddenClass='windowHidden'] - CSS class applied when the page is hidden.
331
201
  * @param {string} [settings.visibleClass='windowVisible'] - CSS class applied when the page is visible.
332
202
  * @param {() => void} [settings.onVisible] - Callback called when page becomes visible.
@@ -335,8 +205,8 @@ export const getHtmlElPadding = (el) => {
335
205
  * @throws {TypeError} If any provided setting is invalid.
336
206
  */
337
207
  export function installWindowHiddenScript({ element = document.body, hiddenClass = 'windowHidden', visibleClass = 'windowVisible', onVisible, onHidden, } = {}) {
338
- if (!(element instanceof HTMLElement))
339
- throw new TypeError(`"element" must be an instance of HTMLElement.`);
208
+ if (!(element instanceof Element))
209
+ throw new TypeError(`"element" must be an instance of Element.`);
340
210
  if (typeof hiddenClass !== 'string')
341
211
  throw new TypeError(`"hiddenClass" must be a string.`);
342
212
  if (typeof visibleClass !== 'string')
@@ -429,29 +299,3 @@ export function installWindowHiddenScript({ element = document.body, hiddenClass
429
299
  handler(simulatedEvent);
430
300
  return uninstall;
431
301
  }
432
- /**
433
- * Checks if the given element is at least partially visible in the viewport.
434
- *
435
- * @param {HTMLElement} element - The DOM element to check.
436
- * @returns {boolean} True if the element is partially in the viewport, false otherwise.
437
- */
438
- export function isInViewport(element) {
439
- const elementTop = element.offsetTop;
440
- const elementBottom = elementTop + element.offsetHeight;
441
- const viewportTop = window.scrollY;
442
- const viewportBottom = viewportTop + window.innerHeight;
443
- return elementBottom > viewportTop && elementTop < viewportBottom;
444
- }
445
- /**
446
- * Checks if the given element is fully visible in the viewport (top and bottom).
447
- *
448
- * @param {HTMLElement} element - The DOM element to check.
449
- * @returns {boolean} True if the element is fully visible in the viewport, false otherwise.
450
- */
451
- export function isScrolledIntoView(element) {
452
- const viewportTop = window.scrollY;
453
- const viewportBottom = viewportTop + window.innerHeight;
454
- const elemTop = element.offsetTop;
455
- const elemBottom = elemTop + element.offsetHeight;
456
- return elemBottom <= viewportBottom && elemTop >= viewportTop;
457
- }
@@ -0,0 +1,124 @@
1
+ 'use strict';
2
+
3
+ var TinyHtml = require('../libs/TinyHtml.cjs');
4
+
5
+ /**
6
+ * Checks if two DOM elements are colliding on the screen.
7
+ *
8
+ * @param {Element} elem1 - First DOM element.
9
+ * @param {Element} elem2 - Second DOM element.
10
+ * @returns {boolean} - Returns true if the elements are colliding.
11
+ * @deprecated - Use TinyHtml.isCollWith instead.
12
+ */
13
+ function areHtmlElsColliding(elem1, elem2) {
14
+ return TinyHtml.isCollWith(elem1, elem2);
15
+ }
16
+
17
+ /**
18
+ * Checks if two DOM elements are colliding on the screen.
19
+ *
20
+ * @param {Element} elem1 - First DOM element.
21
+ * @param {Element} elem2 - Second DOM element.
22
+ * @returns {boolean} - Returns true if the elements are colliding.
23
+ * @deprecated - Use TinyHtml.isCollPerfWith instead.
24
+ */
25
+ function areHtmlElsPerfColliding(elem1, elem2) {
26
+ return TinyHtml.isCollPerfWith(elem1, elem2);
27
+ }
28
+
29
+ ///////////////////////////////////////////////////////////////////////////
30
+
31
+ /**
32
+ * @typedef {import('../libs/TinyHtml.mjs').HtmlElBoxSides} HtmlElBoxSides
33
+ */
34
+
35
+ /**
36
+ * Returns the total border width and individual sides from `border{Side}Width` CSS properties.
37
+ *
38
+ * @param {Element} el - The target DOM element.
39
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border widths, and each side individually.
40
+ * @deprecated - Use TinyHtml.borderWidth instead.
41
+ */
42
+ const getHtmlElBordersWidth = (el) => {
43
+ return TinyHtml.borderWidth(el);
44
+ };
45
+
46
+ /**
47
+ * Returns the total border size and individual sides from `border{Side}` CSS properties.
48
+ *
49
+ * @param {Element} el - The target DOM element.
50
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border sizes, and each side individually.
51
+ * @deprecated - Use TinyHtml.border instead.
52
+ */
53
+ const getHtmlElBorders = (el) => {
54
+ return TinyHtml.border(el);
55
+ };
56
+
57
+ /**
58
+ * Returns the total margin and individual sides from `margin{Side}` CSS properties.
59
+ *
60
+ * @param {Element} el - The target DOM element.
61
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) margins, and each side individually.
62
+ * @deprecated - Use TinyHtml.margin instead.
63
+ */
64
+ const getHtmlElMargin = (el) => {
65
+ return TinyHtml.margin(el);
66
+ };
67
+
68
+ /**
69
+ * Returns the total padding and individual sides from `padding{Side}` CSS properties.
70
+ *
71
+ * @param {Element} el - The target DOM element.
72
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
73
+ * @deprecated - Use TinyHtml.padding instead.
74
+ */
75
+ const getHtmlElPadding = (el) => {
76
+ return TinyHtml.padding(el);
77
+ };
78
+
79
+ /////////////////////////////////////////////////////////////
80
+
81
+ // The new version will receive great modifications, the deprecated code has been preserved for non-glitch designs that are using the original code.
82
+
83
+ /**
84
+ * Checks if the given element is at least partially visible in the viewport.
85
+ *
86
+ * @param {HTMLElement} element - The DOM element to check.
87
+ * @returns {boolean} True if the element is partially in the viewport, false otherwise.
88
+ * @deprecated - Use TinyHtml.isInViewport instead.
89
+ */
90
+ function isInViewport(element) {
91
+ const elementTop = element.offsetTop;
92
+ const elementBottom = elementTop + element.offsetHeight;
93
+
94
+ const viewportTop = window.scrollY;
95
+ const viewportBottom = viewportTop + window.innerHeight;
96
+
97
+ return elementBottom > viewportTop && elementTop < viewportBottom;
98
+ }
99
+
100
+ /**
101
+ * Checks if the given element is fully visible in the viewport (top and bottom).
102
+ *
103
+ * @param {HTMLElement} element - The DOM element to check.
104
+ * @returns {boolean} True if the element is fully visible in the viewport, false otherwise.
105
+ * @deprecated - Use TinyHtml.isScrolledIntoView instead.
106
+ */
107
+ function isScrolledIntoView(element) {
108
+ const viewportTop = window.scrollY;
109
+ const viewportBottom = viewportTop + window.innerHeight;
110
+
111
+ const elemTop = element.offsetTop;
112
+ const elemBottom = elemTop + element.offsetHeight;
113
+
114
+ return elemBottom <= viewportBottom && elemTop >= viewportTop;
115
+ }
116
+
117
+ exports.areHtmlElsColliding = areHtmlElsColliding;
118
+ exports.areHtmlElsPerfColliding = areHtmlElsPerfColliding;
119
+ exports.getHtmlElBorders = getHtmlElBorders;
120
+ exports.getHtmlElBordersWidth = getHtmlElBordersWidth;
121
+ exports.getHtmlElMargin = getHtmlElMargin;
122
+ exports.getHtmlElPadding = getHtmlElPadding;
123
+ exports.isInViewport = isInViewport;
124
+ exports.isScrolledIntoView = isScrolledIntoView;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Checks if two DOM elements are colliding on the screen.
3
+ *
4
+ * @param {Element} elem1 - First DOM element.
5
+ * @param {Element} elem2 - Second DOM element.
6
+ * @returns {boolean} - Returns true if the elements are colliding.
7
+ * @deprecated - Use TinyHtml.isCollWith instead.
8
+ */
9
+ export function areHtmlElsColliding(elem1: Element, elem2: Element): boolean;
10
+ /**
11
+ * Checks if two DOM elements are colliding on the screen.
12
+ *
13
+ * @param {Element} elem1 - First DOM element.
14
+ * @param {Element} elem2 - Second DOM element.
15
+ * @returns {boolean} - Returns true if the elements are colliding.
16
+ * @deprecated - Use TinyHtml.isCollPerfWith instead.
17
+ */
18
+ export function areHtmlElsPerfColliding(elem1: Element, elem2: Element): boolean;
19
+ /**
20
+ * Checks if the given element is at least partially visible in the viewport.
21
+ *
22
+ * @param {HTMLElement} element - The DOM element to check.
23
+ * @returns {boolean} True if the element is partially in the viewport, false otherwise.
24
+ * @deprecated - Use TinyHtml.isInViewport instead.
25
+ */
26
+ export function isInViewport(element: HTMLElement): boolean;
27
+ /**
28
+ * Checks if the given element is fully visible in the viewport (top and bottom).
29
+ *
30
+ * @param {HTMLElement} element - The DOM element to check.
31
+ * @returns {boolean} True if the element is fully visible in the viewport, false otherwise.
32
+ * @deprecated - Use TinyHtml.isScrolledIntoView instead.
33
+ */
34
+ export function isScrolledIntoView(element: HTMLElement): boolean;
35
+ export function getHtmlElBordersWidth(el: Element): HtmlElBoxSides;
36
+ export function getHtmlElBorders(el: Element): HtmlElBoxSides;
37
+ export function getHtmlElMargin(el: Element): HtmlElBoxSides;
38
+ export function getHtmlElPadding(el: Element): HtmlElBoxSides;
39
+ export type HtmlElBoxSides = import("../libs/TinyHtml.mjs").HtmlElBoxSides;
40
+ //# sourceMappingURL=html_deprecated.d.mts.map
@@ -0,0 +1,97 @@
1
+ import TinyHtml from '../libs/TinyHtml.mjs';
2
+ /**
3
+ * Checks if two DOM elements are colliding on the screen.
4
+ *
5
+ * @param {Element} elem1 - First DOM element.
6
+ * @param {Element} elem2 - Second DOM element.
7
+ * @returns {boolean} - Returns true if the elements are colliding.
8
+ * @deprecated - Use TinyHtml.isCollWith instead.
9
+ */
10
+ export function areHtmlElsColliding(elem1, elem2) {
11
+ return TinyHtml.isCollWith(elem1, elem2);
12
+ }
13
+ /**
14
+ * Checks if two DOM elements are colliding on the screen.
15
+ *
16
+ * @param {Element} elem1 - First DOM element.
17
+ * @param {Element} elem2 - Second DOM element.
18
+ * @returns {boolean} - Returns true if the elements are colliding.
19
+ * @deprecated - Use TinyHtml.isCollPerfWith instead.
20
+ */
21
+ export function areHtmlElsPerfColliding(elem1, elem2) {
22
+ return TinyHtml.isCollPerfWith(elem1, elem2);
23
+ }
24
+ ///////////////////////////////////////////////////////////////////////////
25
+ /**
26
+ * @typedef {import('../libs/TinyHtml.mjs').HtmlElBoxSides} HtmlElBoxSides
27
+ */
28
+ /**
29
+ * Returns the total border width and individual sides from `border{Side}Width` CSS properties.
30
+ *
31
+ * @param {Element} el - The target DOM element.
32
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border widths, and each side individually.
33
+ * @deprecated - Use TinyHtml.borderWidth instead.
34
+ */
35
+ export const getHtmlElBordersWidth = (el) => {
36
+ return TinyHtml.borderWidth(el);
37
+ };
38
+ /**
39
+ * Returns the total border size and individual sides from `border{Side}` CSS properties.
40
+ *
41
+ * @param {Element} el - The target DOM element.
42
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) border sizes, and each side individually.
43
+ * @deprecated - Use TinyHtml.border instead.
44
+ */
45
+ export const getHtmlElBorders = (el) => {
46
+ return TinyHtml.border(el);
47
+ };
48
+ /**
49
+ * Returns the total margin and individual sides from `margin{Side}` CSS properties.
50
+ *
51
+ * @param {Element} el - The target DOM element.
52
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) margins, and each side individually.
53
+ * @deprecated - Use TinyHtml.margin instead.
54
+ */
55
+ export const getHtmlElMargin = (el) => {
56
+ return TinyHtml.margin(el);
57
+ };
58
+ /**
59
+ * Returns the total padding and individual sides from `padding{Side}` CSS properties.
60
+ *
61
+ * @param {Element} el - The target DOM element.
62
+ * @returns {HtmlElBoxSides} - Total horizontal (x) and vertical (y) paddings, and each side individually.
63
+ * @deprecated - Use TinyHtml.padding instead.
64
+ */
65
+ export const getHtmlElPadding = (el) => {
66
+ return TinyHtml.padding(el);
67
+ };
68
+ /////////////////////////////////////////////////////////////
69
+ // The new version will receive great modifications, the deprecated code has been preserved for non-glitch designs that are using the original code.
70
+ /**
71
+ * Checks if the given element is at least partially visible in the viewport.
72
+ *
73
+ * @param {HTMLElement} element - The DOM element to check.
74
+ * @returns {boolean} True if the element is partially in the viewport, false otherwise.
75
+ * @deprecated - Use TinyHtml.isInViewport instead.
76
+ */
77
+ export function isInViewport(element) {
78
+ const elementTop = element.offsetTop;
79
+ const elementBottom = elementTop + element.offsetHeight;
80
+ const viewportTop = window.scrollY;
81
+ const viewportBottom = viewportTop + window.innerHeight;
82
+ return elementBottom > viewportTop && elementTop < viewportBottom;
83
+ }
84
+ /**
85
+ * Checks if the given element is fully visible in the viewport (top and bottom).
86
+ *
87
+ * @param {HTMLElement} element - The DOM element to check.
88
+ * @returns {boolean} True if the element is fully visible in the viewport, false otherwise.
89
+ * @deprecated - Use TinyHtml.isScrolledIntoView instead.
90
+ */
91
+ export function isScrolledIntoView(element) {
92
+ const viewportTop = window.scrollY;
93
+ const viewportBottom = viewportTop + window.innerHeight;
94
+ const elemTop = element.offsetTop;
95
+ const elemBottom = elemTop + element.offsetHeight;
96
+ return elemBottom <= viewportBottom && elemTop >= viewportTop;
97
+ }
@@ -5,6 +5,7 @@ var replaceAsync = require('../../legacy/libs/replaceAsync.cjs');
5
5
  var array = require('./array.cjs');
6
6
  var clock = require('./clock.cjs');
7
7
  var html = require('./html.cjs');
8
+ var html_deprecated = require('./html_deprecated.cjs');
8
9
  var objFilter = require('./objFilter.cjs');
9
10
  var fullScreen = require('./fullScreen.cjs');
10
11
  var simpleMath = require('./simpleMath.cjs');
@@ -20,19 +21,19 @@ exports.formatCustomTimer = clock.formatCustomTimer;
20
21
  exports.formatDayTimer = clock.formatDayTimer;
21
22
  exports.formatTimer = clock.formatTimer;
22
23
  exports.getTimeDuration = clock.getTimeDuration;
23
- exports.areHtmlElsColliding = html.areHtmlElsColliding;
24
24
  exports.fetchJson = html.fetchJson;
25
- exports.getHtmlElBorders = html.getHtmlElBorders;
26
- exports.getHtmlElBordersWidth = html.getHtmlElBordersWidth;
27
- exports.getHtmlElMargin = html.getHtmlElMargin;
28
- exports.getHtmlElPadding = html.getHtmlElPadding;
29
25
  exports.installWindowHiddenScript = html.installWindowHiddenScript;
30
- exports.isInViewport = html.isInViewport;
31
- exports.isScrolledIntoView = html.isScrolledIntoView;
32
26
  exports.readBase64Blob = html.readBase64Blob;
33
27
  exports.readFileBlob = html.readFileBlob;
34
28
  exports.readJsonBlob = html.readJsonBlob;
35
29
  exports.saveJsonFile = html.saveJsonFile;
30
+ exports.areHtmlElsColliding = html_deprecated.areHtmlElsColliding;
31
+ exports.getHtmlElBorders = html_deprecated.getHtmlElBorders;
32
+ exports.getHtmlElBordersWidth = html_deprecated.getHtmlElBordersWidth;
33
+ exports.getHtmlElMargin = html_deprecated.getHtmlElMargin;
34
+ exports.getHtmlElPadding = html_deprecated.getHtmlElPadding;
35
+ exports.isInViewport = html_deprecated.isInViewport;
36
+ exports.isScrolledIntoView = html_deprecated.isScrolledIntoView;
36
37
  exports.cloneObjTypeOrder = objFilter.cloneObjTypeOrder;
37
38
  exports.countObj = objFilter.countObj;
38
39
  exports.extendObjType = objFilter.extendObjType;
@@ -16,15 +16,15 @@ import { getRectCenter } from './collision.mjs';
16
16
  import { getElsRelativeCenterOffset } from './collision.mjs';
17
17
  import { getElsCollDirDepth } from './collision.mjs';
18
18
  import { getElsCollDetails } from './collision.mjs';
19
- import { isInViewport } from './html.mjs';
20
- import { isScrolledIntoView } from './html.mjs';
19
+ import { isInViewport } from './html_deprecated.mjs';
20
+ import { isScrolledIntoView } from './html_deprecated.mjs';
21
21
  import { safeTextTrim } from './text.mjs';
22
22
  import { installWindowHiddenScript } from './html.mjs';
23
23
  import { genFibonacciSeq } from './simpleMath.mjs';
24
- import { getHtmlElBorders } from './html.mjs';
25
- import { getHtmlElBordersWidth } from './html.mjs';
26
- import { getHtmlElMargin } from './html.mjs';
27
- import { getHtmlElPadding } from './html.mjs';
24
+ import { getHtmlElBorders } from './html_deprecated.mjs';
25
+ import { getHtmlElBordersWidth } from './html_deprecated.mjs';
26
+ import { getHtmlElMargin } from './html_deprecated.mjs';
27
+ import { getHtmlElPadding } from './html_deprecated.mjs';
28
28
  import { fetchJson } from './html.mjs';
29
29
  import { readJsonBlob } from './html.mjs';
30
30
  import { readFileBlob } from './html.mjs';
@@ -37,7 +37,7 @@ import { exitFullScreen } from './fullScreen.mjs';
37
37
  import { isFullScreenMode } from './fullScreen.mjs';
38
38
  import { onFullScreenChange } from './fullScreen.mjs';
39
39
  import { offFullScreenChange } from './fullScreen.mjs';
40
- import { areHtmlElsColliding } from './html.mjs';
40
+ import { areHtmlElsColliding } from './html_deprecated.mjs';
41
41
  import { isJsonObject } from './objFilter.mjs';
42
42
  import arraySortPositions from '../../legacy/libs/arraySortPositions.mjs';
43
43
  import { formatBytes } from './simpleMath.mjs';
@@ -2,7 +2,8 @@ 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, isInViewport, isScrolledIntoView, } from './html.mjs';
5
+ import { readJsonBlob, saveJsonFile, fetchJson, installWindowHiddenScript, readFileBlob, readBase64Blob, } from './html.mjs';
6
+ import { areHtmlElsColliding, getHtmlElBorders, getHtmlElBordersWidth, getHtmlElMargin, getHtmlElPadding, isInViewport, isScrolledIntoView, } from './html_deprecated.mjs';
6
7
  import { countObj, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, isJsonObject, } from './objFilter.mjs';
7
8
  import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, } from './fullScreen.mjs';
8
9
  import { formatBytes, genFibonacciSeq, getAge, getSimplePerc, ruleOfThree } from './simpleMath.mjs';
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var TinyAfterScrollWatcher = require('../libs/TinyAfterScrollWatcher.cjs');
4
+
5
+
6
+
7
+ exports.TinyAfterScrollWatcher = TinyAfterScrollWatcher;
@@ -0,0 +1,3 @@
1
+ export { TinyAfterScrollWatcher };
2
+ import TinyAfterScrollWatcher from '../libs/TinyAfterScrollWatcher.mjs';
3
+ //# sourceMappingURL=TinyAfterScrollWatcher.d.mts.map
@@ -0,0 +1,2 @@
1
+ import TinyAfterScrollWatcher from '../libs/TinyAfterScrollWatcher.mjs';
2
+ export { TinyAfterScrollWatcher };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var TinyHtml = require('../libs/TinyHtml.cjs');
4
+
5
+
6
+
7
+ exports.TinyHtml = TinyHtml;
@@ -0,0 +1,3 @@
1
+ export { TinyHtml };
2
+ import TinyHtml from '../libs/TinyHtml.mjs';
3
+ //# sourceMappingURL=TinyHtml.d.mts.map
@@ -0,0 +1,2 @@
1
+ import TinyHtml from '../libs/TinyHtml.mjs';
2
+ export { TinyHtml };
package/dist/v1/index.cjs CHANGED
@@ -15,6 +15,7 @@ var TinyRateLimiter = require('./libs/TinyRateLimiter.cjs');
15
15
  var TinyNotifyCenter = require('./libs/TinyNotifyCenter.cjs');
16
16
  var TinyToastNotify = require('./libs/TinyToastNotify.cjs');
17
17
  var html = require('./basics/html.cjs');
18
+ var html_deprecated = require('./basics/html_deprecated.cjs');
18
19
  var TinyDragDropDetector = require('./libs/TinyDragDropDetector.cjs');
19
20
  var normalFuncs = require('./fileManager/normalFuncs.cjs');
20
21
  var asyncFuncs = require('./fileManager/asyncFuncs.cjs');
@@ -22,6 +23,8 @@ var TinyDragger = require('./libs/TinyDragger.cjs');
22
23
  var TinyDomReadyManager = require('./libs/TinyDomReadyManager.cjs');
23
24
  var TinyNotifications = require('./libs/TinyNotifications.cjs');
24
25
  var collision = require('./basics/collision.cjs');
26
+ var TinyHtml = require('./libs/TinyHtml.cjs');
27
+ var TinyAfterScrollWatcher = require('./libs/TinyAfterScrollWatcher.cjs');
25
28
 
26
29
 
27
30
 
@@ -61,19 +64,19 @@ exports.TinyPromiseQueue = TinyPromiseQueue;
61
64
  exports.TinyRateLimiter = TinyRateLimiter;
62
65
  exports.TinyNotifyCenter = TinyNotifyCenter;
63
66
  exports.TinyToastNotify = TinyToastNotify;
64
- exports.areHtmlElsColliding = html.areHtmlElsColliding;
65
67
  exports.fetchJson = html.fetchJson;
66
- exports.getHtmlElBorders = html.getHtmlElBorders;
67
- exports.getHtmlElBordersWidth = html.getHtmlElBordersWidth;
68
- exports.getHtmlElMargin = html.getHtmlElMargin;
69
- exports.getHtmlElPadding = html.getHtmlElPadding;
70
68
  exports.installWindowHiddenScript = html.installWindowHiddenScript;
71
- exports.isInViewport = html.isInViewport;
72
- exports.isScrolledIntoView = html.isScrolledIntoView;
73
69
  exports.readBase64Blob = html.readBase64Blob;
74
70
  exports.readFileBlob = html.readFileBlob;
75
71
  exports.readJsonBlob = html.readJsonBlob;
76
72
  exports.saveJsonFile = html.saveJsonFile;
73
+ exports.areHtmlElsColliding = html_deprecated.areHtmlElsColliding;
74
+ exports.getHtmlElBorders = html_deprecated.getHtmlElBorders;
75
+ exports.getHtmlElBordersWidth = html_deprecated.getHtmlElBordersWidth;
76
+ exports.getHtmlElMargin = html_deprecated.getHtmlElMargin;
77
+ exports.getHtmlElPadding = html_deprecated.getHtmlElPadding;
78
+ exports.isInViewport = html_deprecated.isInViewport;
79
+ exports.isScrolledIntoView = html_deprecated.isScrolledIntoView;
77
80
  exports.TinyDragDropDetector = TinyDragDropDetector;
78
81
  exports.backupFile = normalFuncs.backupFile;
79
82
  exports.clearDirectory = normalFuncs.clearDirectory;
@@ -124,3 +127,5 @@ exports.getElsColliding = collision.getElsColliding;
124
127
  exports.getElsPerfColliding = collision.getElsPerfColliding;
125
128
  exports.getElsRelativeCenterOffset = collision.getElsRelativeCenterOffset;
126
129
  exports.getRectCenter = collision.getRectCenter;
130
+ exports.TinyHtml = TinyHtml;
131
+ exports.TinyAfterScrollWatcher = TinyAfterScrollWatcher;