@vettvangur/vanilla 0.0.3 → 0.0.4
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/index.esm.js +35 -6
- package/dist/types/index.d.ts +16 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -416,11 +416,40 @@ function onDomReady(moduleMap, initCoreScriptsCallback, callback = null) {
|
|
|
416
416
|
*/
|
|
417
417
|
function onPopstate(moduleMap, initCoreScriptsCallback, callback = null) {
|
|
418
418
|
window.addEventListener('popstate', e => {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
callback
|
|
423
|
-
|
|
419
|
+
setTimeout(() => {
|
|
420
|
+
initCoreScripts(initCoreScriptsCallback);
|
|
421
|
+
lazyModules(moduleMap);
|
|
422
|
+
if (callback) {
|
|
423
|
+
callback(e);
|
|
424
|
+
}
|
|
425
|
+
}, 0);
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Handles the "pageshow" functionality by listening for the popstate event.
|
|
431
|
+
*
|
|
432
|
+
* Although named "onPageShow", this function currently uses the "popstate" event as a trigger.
|
|
433
|
+
* After a short delay, it initializes core scripts and lazy loads modules based on the provided module map.
|
|
434
|
+
* An optional callback is executed with the event object if supplied.
|
|
435
|
+
*
|
|
436
|
+
* @function onPageShow
|
|
437
|
+
* @param {Map} moduleMap - The compiled module map for lazy loading.
|
|
438
|
+
* @param {Function} initCoreScriptsCallback - The callback function used to initialize core scripts.
|
|
439
|
+
* @param {Function} [callback] - An optional callback to execute during event handling.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* onPageShow(moduleMap, () => { console.log('Core scripts initialized'); }, (e) => { console.log('Pageshow event triggered', e); });
|
|
443
|
+
*/
|
|
444
|
+
function onPageShow(moduleMap, initCoreScriptsCallback, callback = null) {
|
|
445
|
+
window.addEventListener('pageShow', e => {
|
|
446
|
+
setTimeout(() => {
|
|
447
|
+
initCoreScripts(initCoreScriptsCallback);
|
|
448
|
+
lazyModules(moduleMap);
|
|
449
|
+
if (callback) {
|
|
450
|
+
callback(e);
|
|
451
|
+
}
|
|
452
|
+
}, 0);
|
|
424
453
|
});
|
|
425
454
|
}
|
|
426
455
|
|
|
@@ -584,4 +613,4 @@ function clickOutside(callback) {
|
|
|
584
613
|
});
|
|
585
614
|
}
|
|
586
615
|
|
|
587
|
-
export { capitalize, clickOutside, createModuleMap, dictionary, fetcher, flatten, getTemplate, initCoreScripts, isEmpty, lazyModules, loadEnvFiles, onDomReady, onHtmxAfterSettle, onHtmxAfterSwap, onHtmxBeforeSwap, onPopstate, preloadTimeout, regexr };
|
|
616
|
+
export { capitalize, clickOutside, createModuleMap, dictionary, fetcher, flatten, getTemplate, initCoreScripts, isEmpty, lazyModules, loadEnvFiles, onDomReady, onHtmxAfterSettle, onHtmxAfterSwap, onHtmxBeforeSwap, onPageShow, onPopstate, preloadTimeout, regexr };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -163,6 +163,22 @@ export function onDomReady(moduleMap: Map<any, any>, initCoreScriptsCallback: Fu
|
|
|
163
163
|
* onPopstate(moduleMap, () => { console.log('Core scripts initialized'); }, () => { console.log('Popstate event triggered'); });
|
|
164
164
|
*/
|
|
165
165
|
export function onPopstate(moduleMap: Map<any, any>, initCoreScriptsCallback: Function, callback?: Function): void;
|
|
166
|
+
/**
|
|
167
|
+
* Handles the "pageshow" functionality by listening for the popstate event.
|
|
168
|
+
*
|
|
169
|
+
* Although named "onPageShow", this function currently uses the "popstate" event as a trigger.
|
|
170
|
+
* After a short delay, it initializes core scripts and lazy loads modules based on the provided module map.
|
|
171
|
+
* An optional callback is executed with the event object if supplied.
|
|
172
|
+
*
|
|
173
|
+
* @function onPageShow
|
|
174
|
+
* @param {Map} moduleMap - The compiled module map for lazy loading.
|
|
175
|
+
* @param {Function} initCoreScriptsCallback - The callback function used to initialize core scripts.
|
|
176
|
+
* @param {Function} [callback] - An optional callback to execute during event handling.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* onPageShow(moduleMap, () => { console.log('Core scripts initialized'); }, (e) => { console.log('Pageshow event triggered', e); });
|
|
180
|
+
*/
|
|
181
|
+
export function onPageShow(moduleMap: Map<any, any>, initCoreScriptsCallback: Function, callback?: Function): void;
|
|
166
182
|
/**
|
|
167
183
|
* Handles the `htmx:beforeSwap` event to perform actions before HTMX swaps.
|
|
168
184
|
*
|