tiny-essentials 1.20.0 → 1.20.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/README.md +5 -0
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/basics/html.cjs +33 -2
- package/dist/v1/basics/html.d.mts +14 -4
- package/dist/v1/basics/html.mjs +27 -2
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +3 -1
- package/dist/v1/basics/index.mjs +3 -3
- package/dist/v1/basics/simpleMath.cjs +23 -4
- package/dist/v1/basics/simpleMath.d.mts +18 -4
- package/dist/v1/basics/simpleMath.mjs +22 -4
- package/dist/v1/index.cjs +2 -0
- package/dist/v1/index.d.mts +3 -1
- package/dist/v1/index.mjs +3 -3
- package/dist/v1/libs/TinyDragger.cjs +1 -1
- package/dist/v1/libs/TinyDragger.mjs +1 -1
- package/dist/v1/libs/TinyHtml.cjs +500 -105
- package/dist/v1/libs/TinyHtml.d.mts +251 -42
- package/dist/v1/libs/TinyHtml.mjs +448 -96
- package/dist/v1/libs/TinyIframeEvents.cjs +2 -1
- package/dist/v1/libs/TinyNewWinEvents.cjs +4 -2
- package/docs/v1/basics/html.md +78 -22
- package/docs/v1/basics/simpleMath.md +22 -4
- package/docs/v1/libs/TinyHtml.md +268 -6
- package/package.json +1 -1
- package/dist/v1/ColorSafeStringify.js +0 -235
- package/dist/v1/TinyAfterScrollWatcher.js +0 -219
- package/dist/v1/TinyBasicsEs.js +0 -9334
- package/dist/v1/TinyClipboard.js +0 -459
- package/dist/v1/TinyColorConverter.js +0 -617
- package/dist/v1/TinyDomReadyManager.js +0 -213
- package/dist/v1/TinyDragDropDetector.js +0 -307
- package/dist/v1/TinyDragger.js +0 -6569
- package/dist/v1/TinyEssentials.js +0 -20792
- package/dist/v1/TinyEvents.js +0 -402
- package/dist/v1/TinyHtml.js +0 -5545
- package/dist/v1/TinyIframeEvents.js +0 -854
- package/dist/v1/TinyLevelUp.js +0 -291
- package/dist/v1/TinyLocalStorage.js +0 -1440
- package/dist/v1/TinyNewWinEvents.js +0 -888
- package/dist/v1/TinyNotifications.js +0 -408
- package/dist/v1/TinyNotifyCenter.js +0 -493
- package/dist/v1/TinyPromiseQueue.js +0 -299
- package/dist/v1/TinyRateLimiter.js +0 -611
- package/dist/v1/TinySmartScroller.js +0 -7039
- package/dist/v1/TinyTextRangeEditor.js +0 -497
- package/dist/v1/TinyTimeout.js +0 -233
- package/dist/v1/TinyToastNotify.js +0 -441
- package/dist/v1/TinyUploadClicker.js +0 -14353
- package/dist/v1/UltraRandomMsgGen.js +0 -995
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
/******/ (() => { // webpackBootstrap
|
|
2
|
-
/******/ "use strict";
|
|
3
|
-
/******/ // The require scope
|
|
4
|
-
/******/ var __webpack_require__ = {};
|
|
5
|
-
/******/
|
|
6
|
-
/************************************************************************/
|
|
7
|
-
/******/ /* webpack/runtime/define property getters */
|
|
8
|
-
/******/ (() => {
|
|
9
|
-
/******/ // define getter functions for harmony exports
|
|
10
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
11
|
-
/******/ for(var key in definition) {
|
|
12
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
13
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
14
|
-
/******/ }
|
|
15
|
-
/******/ }
|
|
16
|
-
/******/ };
|
|
17
|
-
/******/ })();
|
|
18
|
-
/******/
|
|
19
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
20
|
-
/******/ (() => {
|
|
21
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
22
|
-
/******/ })();
|
|
23
|
-
/******/
|
|
24
|
-
/************************************************************************/
|
|
25
|
-
var __webpack_exports__ = {};
|
|
26
|
-
|
|
27
|
-
// EXPORTS
|
|
28
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
-
ColorSafeStringify: () => (/* reexport */ libs_ColorSafeStringify)
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
;// ./src/v1/libs/ColorSafeStringify.mjs
|
|
33
|
-
/**
|
|
34
|
-
* @typedef {Record<string, string>} ColorsList
|
|
35
|
-
* Represents a mapping of color keys to ANSI escape codes.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
class ColorSafeStringify {
|
|
39
|
-
/**
|
|
40
|
-
* Currently active color configuration.
|
|
41
|
-
* @type {ColorsList}
|
|
42
|
-
*/
|
|
43
|
-
#colors;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Preset collections (internal and user-defined).
|
|
47
|
-
* @type {Record<string, ColorsList>}
|
|
48
|
-
* @static
|
|
49
|
-
*/
|
|
50
|
-
static #PRESETS = {
|
|
51
|
-
default: {
|
|
52
|
-
reset: '\x1b[0m',
|
|
53
|
-
key: '\x1b[36m', // Cyan (object keys)
|
|
54
|
-
string: '\x1b[32m', // Green (regular strings)
|
|
55
|
-
string_url: '\x1b[34m', // Blue (URLs)
|
|
56
|
-
string_bool: '\x1b[35m', // Magenta (boolean/null in string form)
|
|
57
|
-
string_number: '\x1b[33m', // Yellow (numbers in string form)
|
|
58
|
-
number: '\x1b[33m', // Yellow (raw numbers)
|
|
59
|
-
boolean: '\x1b[35m', // Magenta (true/false)
|
|
60
|
-
null: '\x1b[1;30m', // Gray (null)
|
|
61
|
-
special: '\x1b[31m', // Red (e.g., [Circular], [undefined])
|
|
62
|
-
func: '\x1b[90m', // Dim (function string representations)
|
|
63
|
-
},
|
|
64
|
-
solarized: {
|
|
65
|
-
reset: '\x1b[0m',
|
|
66
|
-
key: '\x1b[38;5;37m',
|
|
67
|
-
string: '\x1b[38;5;136m',
|
|
68
|
-
string_url: '\x1b[38;5;33m',
|
|
69
|
-
string_bool: '\x1b[38;5;166m',
|
|
70
|
-
string_number: '\x1b[38;5;136m',
|
|
71
|
-
number: '\x1b[38;5;136m',
|
|
72
|
-
boolean: '\x1b[38;5;166m',
|
|
73
|
-
null: '\x1b[38;5;241m',
|
|
74
|
-
special: '\x1b[38;5;160m',
|
|
75
|
-
func: '\x1b[38;5;244m',
|
|
76
|
-
},
|
|
77
|
-
monokai: {
|
|
78
|
-
reset: '\x1b[0m',
|
|
79
|
-
key: '\x1b[38;5;81m',
|
|
80
|
-
string: '\x1b[38;5;114m',
|
|
81
|
-
string_url: '\x1b[38;5;75m',
|
|
82
|
-
string_bool: '\x1b[38;5;204m',
|
|
83
|
-
string_number: '\x1b[38;5;221m',
|
|
84
|
-
number: '\x1b[38;5;221m',
|
|
85
|
-
boolean: '\x1b[38;5;204m',
|
|
86
|
-
null: '\x1b[38;5;241m',
|
|
87
|
-
special: '\x1b[38;5;160m',
|
|
88
|
-
func: '\x1b[38;5;102m',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Constructs a new instance with an optional base preset or custom override.
|
|
94
|
-
* @param {ColorsList} [defaultColors] - Optional override for the default color scheme.
|
|
95
|
-
*/
|
|
96
|
-
constructor(defaultColors = {}) {
|
|
97
|
-
this.#colors = { ...ColorSafeStringify.#PRESETS.default, ...defaultColors };
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Internal method to apply ANSI color codes to different parts of a JSON string.
|
|
102
|
-
* @param {string} str - Raw JSON string to be colorized.
|
|
103
|
-
* @param {ColorsList} colors - ANSI color mapping to be applied to each JSON element type.
|
|
104
|
-
* @returns {string} Colorized JSON string.
|
|
105
|
-
*/
|
|
106
|
-
#colorizeJSON(str, colors) {
|
|
107
|
-
/** @type {{ marker: string, key: string }[]} */
|
|
108
|
-
const keyMatches = [];
|
|
109
|
-
|
|
110
|
-
// Colorize numeric values
|
|
111
|
-
str = str.replace(
|
|
112
|
-
/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,
|
|
113
|
-
`${colors.number}$1${colors.reset}`,
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
// Replace keys with temporary markers for later colorization
|
|
117
|
-
str = str.replace(/"([^"]+)":/g, (_, key) => {
|
|
118
|
-
const marker = `___KEY${keyMatches.length}___`;
|
|
119
|
-
keyMatches.push({ marker, key });
|
|
120
|
-
return `${marker}:`; // Keep the colon for valid syntax
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// Replace strings and apply specific colors based on their content
|
|
124
|
-
str = str.replace(/"(?:\\.|[^"\\])*?"/g, (match) => {
|
|
125
|
-
const val = match.slice(1, -1); // Remove surrounding quotes
|
|
126
|
-
|
|
127
|
-
if (/^(https?|ftp):\/\/[^\s]+$/i.test(val)) {
|
|
128
|
-
return `${colors.string_url}${match}${colors.reset}`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (/^(true|false|null)$/.test(val)) {
|
|
132
|
-
return `${colors.string_bool}${match}${colors.reset}`;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(val)) {
|
|
136
|
-
return `${colors.string_number}${match}${colors.reset}`;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return `${colors.string}${match}${colors.reset}`;
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// Replace markers with colorized keys
|
|
143
|
-
for (const { marker, key } of keyMatches) {
|
|
144
|
-
const regex = new RegExp(marker, 'g');
|
|
145
|
-
str = str.replace(regex, `${colors.key}"${key}"${colors.reset}`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Colorize boolean values
|
|
149
|
-
str = str.replace(/(?<!")\b(true|false)\b(?!")/g, `${colors.boolean}$1${colors.reset}`);
|
|
150
|
-
|
|
151
|
-
// Colorize null values
|
|
152
|
-
str = str.replace(/(?<!")\bnull\b(?!")/g, `${colors.null}null${colors.reset}`);
|
|
153
|
-
|
|
154
|
-
// Highlight special placeholder values
|
|
155
|
-
str = str.replace(/\[Circular\]/g, `${colors.special}[Circular]${colors.reset}`);
|
|
156
|
-
str = str.replace(/\[undefined\]/g, `${colors.special}[undefined]${colors.reset}`);
|
|
157
|
-
|
|
158
|
-
// Colorize function string representations
|
|
159
|
-
str = str.replace(/"function.*?[^\\]"/gs, `${colors.func}$&${colors.reset}`);
|
|
160
|
-
return str;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Colorizes a JSON string using the active or optionally overridden color set.
|
|
165
|
-
* @param {string} json - The JSON string to format.
|
|
166
|
-
* @param {ColorsList} [customColors] - Optional temporary color override.
|
|
167
|
-
* @returns {string}
|
|
168
|
-
*/
|
|
169
|
-
colorize(json, customColors = {}) {
|
|
170
|
-
const colors = { ...this.#colors, ...customColors };
|
|
171
|
-
return this.#colorizeJSON(json, colors);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Returns the currently active color scheme.
|
|
176
|
-
* @returns {ColorsList}
|
|
177
|
-
*/
|
|
178
|
-
getColors() {
|
|
179
|
-
return { ...this.#colors };
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Updates the current color scheme with a partial override.
|
|
184
|
-
* @param {Partial<ColorsList>} newColors
|
|
185
|
-
*/
|
|
186
|
-
updateColors(newColors) {
|
|
187
|
-
Object.assign(this.#colors, newColors);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Resets the current color scheme to the default preset.
|
|
192
|
-
*/
|
|
193
|
-
resetColors() {
|
|
194
|
-
this.#colors = { ...ColorSafeStringify.#PRESETS.default };
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Loads a color preset by name.
|
|
199
|
-
* @param {string} presetName - Name of the preset to load.
|
|
200
|
-
* @throws Will throw if the preset doesn't exist.
|
|
201
|
-
*/
|
|
202
|
-
loadColorPreset(presetName) {
|
|
203
|
-
const preset = ColorSafeStringify.#PRESETS[presetName];
|
|
204
|
-
if (!preset) throw new Error(`Preset "${presetName}" not found.`);
|
|
205
|
-
this.#colors = { ...preset };
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Saves a new custom color preset.
|
|
210
|
-
* @param {string} name - Name of the new preset.
|
|
211
|
-
* @param {ColorsList} colors - ANSI color map to save.
|
|
212
|
-
*/
|
|
213
|
-
saveColorPreset(name, colors) {
|
|
214
|
-
ColorSafeStringify.#PRESETS[name] = { ...colors };
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Returns a list of all available color preset names.
|
|
219
|
-
* @returns {string[]}
|
|
220
|
-
*/
|
|
221
|
-
getAvailablePresets() {
|
|
222
|
-
return Object.keys(ColorSafeStringify.#PRESETS);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/* harmony default export */ const libs_ColorSafeStringify = (ColorSafeStringify);
|
|
227
|
-
|
|
228
|
-
;// ./src/v1/build/ColorSafeStringify.mjs
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
window.ColorSafeStringify = __webpack_exports__.ColorSafeStringify;
|
|
234
|
-
/******/ })()
|
|
235
|
-
;
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
/******/ (() => { // webpackBootstrap
|
|
2
|
-
/******/ "use strict";
|
|
3
|
-
/******/ // The require scope
|
|
4
|
-
/******/ var __webpack_require__ = {};
|
|
5
|
-
/******/
|
|
6
|
-
/************************************************************************/
|
|
7
|
-
/******/ /* webpack/runtime/define property getters */
|
|
8
|
-
/******/ (() => {
|
|
9
|
-
/******/ // define getter functions for harmony exports
|
|
10
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
11
|
-
/******/ for(var key in definition) {
|
|
12
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
13
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
14
|
-
/******/ }
|
|
15
|
-
/******/ }
|
|
16
|
-
/******/ };
|
|
17
|
-
/******/ })();
|
|
18
|
-
/******/
|
|
19
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
20
|
-
/******/ (() => {
|
|
21
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
22
|
-
/******/ })();
|
|
23
|
-
/******/
|
|
24
|
-
/************************************************************************/
|
|
25
|
-
var __webpack_exports__ = {};
|
|
26
|
-
|
|
27
|
-
// EXPORTS
|
|
28
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
29
|
-
TinyAfterScrollWatcher: () => (/* reexport */ libs_TinyAfterScrollWatcher)
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
;// ./src/v1/libs/TinyAfterScrollWatcher.mjs
|
|
33
|
-
/**
|
|
34
|
-
* @typedef {(() => void)} FnData - Function with no arguments and no return value
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A function that handles a scroll event.
|
|
39
|
-
* It receives a standard `Event` object when a scroll occurs.
|
|
40
|
-
*
|
|
41
|
-
* @typedef {(ev: Event) => void} OnScrollFunc
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* A scroll tracker that queues functions to be executed
|
|
46
|
-
* after the user stops scrolling a specific element or the window.
|
|
47
|
-
*/
|
|
48
|
-
class TinyAfterScrollWatcher {
|
|
49
|
-
/** @type {Element|Window} */
|
|
50
|
-
#scrollTarget;
|
|
51
|
-
|
|
52
|
-
/** @type {null|NodeJS.Timeout} */
|
|
53
|
-
#lastScrollTime = null;
|
|
54
|
-
|
|
55
|
-
/** @type {FnData[]} */
|
|
56
|
-
#afterScrollQueue = [];
|
|
57
|
-
|
|
58
|
-
/** @type {number} */
|
|
59
|
-
#inactivityTime = 100;
|
|
60
|
-
|
|
61
|
-
/** @type {Set<OnScrollFunc>} */
|
|
62
|
-
#externalScrollListeners = new Set();
|
|
63
|
-
|
|
64
|
-
/** @type {Set<FnData>} */
|
|
65
|
-
#onStopListeners = new Set();
|
|
66
|
-
|
|
67
|
-
/** @type {boolean} */
|
|
68
|
-
#destroyed = false;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @param {Element|Window} scrollTarget - The element or window to track scrolling on
|
|
72
|
-
* @param {number} [inactivityTime=100] - Time in milliseconds to wait after scroll ends before executing the queue
|
|
73
|
-
* @throws {TypeError} If scrollTarget is not a valid Element or Window
|
|
74
|
-
* @throws {TypeError} If inactivityTime is not a positive number
|
|
75
|
-
*/
|
|
76
|
-
constructor(scrollTarget = window, inactivityTime = 100) {
|
|
77
|
-
if (!(scrollTarget instanceof Element) && !(scrollTarget instanceof Window))
|
|
78
|
-
throw new TypeError('scrollTarget must be an Element or the Window object.');
|
|
79
|
-
this.#scrollTarget = scrollTarget;
|
|
80
|
-
this._checkTimer = this._checkTimer.bind(this);
|
|
81
|
-
|
|
82
|
-
this.#scrollTarget.addEventListener('scroll', this._checkTimer);
|
|
83
|
-
this.#inactivityTime = inactivityTime;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
_checkTimer = () => {
|
|
87
|
-
if (this.#lastScrollTime) clearTimeout(this.#lastScrollTime);
|
|
88
|
-
this.#lastScrollTime = setTimeout(() => {
|
|
89
|
-
this.#lastScrollTime = null;
|
|
90
|
-
this.#checkQueue();
|
|
91
|
-
}, this.#inactivityTime);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Gets the current inactivity time in milliseconds.
|
|
96
|
-
* @returns {number}
|
|
97
|
-
*/
|
|
98
|
-
get inactivityTime() {
|
|
99
|
-
return this.#inactivityTime;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Sets a new inactivity time.
|
|
104
|
-
* Must be a positive number (in milliseconds).
|
|
105
|
-
* @param {number} value
|
|
106
|
-
* @throws {Error} If value is not a positive number
|
|
107
|
-
*/
|
|
108
|
-
set inactivityTime(value) {
|
|
109
|
-
if (typeof value !== 'number' || value <= 0 || !Number.isFinite(value))
|
|
110
|
-
throw new Error('inactivityTime must be a positive number in milliseconds.');
|
|
111
|
-
this.#inactivityTime = value;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Continuously checks whether the user has stopped scrolling,
|
|
116
|
-
* and if so, runs all queued functions.
|
|
117
|
-
*/
|
|
118
|
-
#checkQueue() {
|
|
119
|
-
if (this.#destroyed) return;
|
|
120
|
-
// Runs all onStop first listeners
|
|
121
|
-
for (const fn of this.#onStopListeners) {
|
|
122
|
-
if (typeof fn === 'function') fn();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Then execute the queue afterScrollQueue
|
|
126
|
-
while (this.#afterScrollQueue.length) {
|
|
127
|
-
const fn = this.#afterScrollQueue.pop();
|
|
128
|
-
if (typeof fn === 'function') fn();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Adds a function to be executed after scroll has stopped.
|
|
134
|
-
* The scroll is considered "stopped" after the configured inactivity time.
|
|
135
|
-
*
|
|
136
|
-
* @param {() => void} fn - A function to execute once scrolling has stopped.
|
|
137
|
-
* @throws {TypeError} If the argument is not a function.
|
|
138
|
-
*/
|
|
139
|
-
doAfterScroll(fn) {
|
|
140
|
-
if (typeof fn !== 'function') throw new TypeError('Argument must be a function.');
|
|
141
|
-
this.lastScrollTime = Date.now();
|
|
142
|
-
this.#afterScrollQueue.push(fn);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Registers a function to run once after scrolling has stopped,
|
|
147
|
-
* before any afterScrollQueue functions.
|
|
148
|
-
*
|
|
149
|
-
* @param {FnData} fn - A function to execute after scroll stop.
|
|
150
|
-
* @throws {TypeError} If the argument is not a function.
|
|
151
|
-
*/
|
|
152
|
-
onStop(fn) {
|
|
153
|
-
if (typeof fn !== 'function') throw new TypeError('Argument must be a function.');
|
|
154
|
-
this.#onStopListeners.add(fn);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Removes a previously registered onStop function.
|
|
159
|
-
*
|
|
160
|
-
* @param {FnData} fn - The function to remove.
|
|
161
|
-
* @throws {TypeError} If the argument is not a function.
|
|
162
|
-
*/
|
|
163
|
-
offStop(fn) {
|
|
164
|
-
if (typeof fn !== 'function') throw new TypeError('Argument must be a function.');
|
|
165
|
-
this.#onStopListeners.delete(fn);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Registers an external scroll listener on the tracked element.
|
|
170
|
-
*
|
|
171
|
-
* @param {OnScrollFunc} fn - The scroll listener to add
|
|
172
|
-
* @throws {TypeError} If the argument is not a function.
|
|
173
|
-
*/
|
|
174
|
-
onScroll(fn) {
|
|
175
|
-
if (typeof fn !== 'function') throw new TypeError('Argument must be a function.');
|
|
176
|
-
this.#scrollTarget.addEventListener('scroll', fn);
|
|
177
|
-
this.#externalScrollListeners.add(fn);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Removes a previously registered scroll listener from the tracked element.
|
|
182
|
-
*
|
|
183
|
-
* @param {OnScrollFunc} fn - The scroll listener to remove
|
|
184
|
-
* @throws {TypeError} If the argument is not a function.
|
|
185
|
-
*/
|
|
186
|
-
offScroll(fn) {
|
|
187
|
-
if (typeof fn !== 'function') throw new TypeError('Argument must be a function.');
|
|
188
|
-
if (this.#externalScrollListeners.has(fn)) {
|
|
189
|
-
this.#scrollTarget.removeEventListener('scroll', fn);
|
|
190
|
-
this.#externalScrollListeners.delete(fn);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Destroys the watcher by removing internal listeners and clearing data.
|
|
196
|
-
*/
|
|
197
|
-
destroy() {
|
|
198
|
-
if (this.#destroyed) return;
|
|
199
|
-
this.#destroyed = true;
|
|
200
|
-
|
|
201
|
-
this.#scrollTarget.removeEventListener('scroll', this._checkTimer);
|
|
202
|
-
for (const fn of this.#externalScrollListeners)
|
|
203
|
-
this.#scrollTarget.removeEventListener('scroll', fn);
|
|
204
|
-
|
|
205
|
-
this.#externalScrollListeners.clear();
|
|
206
|
-
this.#onStopListeners.clear();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/* harmony default export */ const libs_TinyAfterScrollWatcher = (TinyAfterScrollWatcher);
|
|
211
|
-
|
|
212
|
-
;// ./src/v1/build/TinyAfterScrollWatcher.mjs
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
window.TinyAfterScrollWatcher = __webpack_exports__.TinyAfterScrollWatcher;
|
|
218
|
-
/******/ })()
|
|
219
|
-
;
|