pagewave 1.0.4 → 1.0.6

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/package.json CHANGED
@@ -1,12 +1,29 @@
1
1
  {
2
2
  "name": "pagewave",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "NPM Package for implementing page transitions in both SSR and CSR apps. Utilize both custom and preset animations. Choose between transitions, keyframe animations, and overlays.",
5
- "main": "transition.js",
6
- "type": "module",
7
- "style": ["KeyFramePreset.css", "OverlayPreset.css"],
5
+ "main": "./dist/index.js",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.mjs",
9
+ "require": "./dist/index.js"
10
+ },
11
+ "./OverlayPreset.css": {
12
+ "import": "./dist/OverlayPreset.css",
13
+ "require": "./dist/OverlayPreset.css"
14
+ },
15
+ "./KeyFramePreset.css": {
16
+ "import": "./dist/KeyFramePreset.css",
17
+ "require": "./dist/KeyFramePreset.css"
18
+ }
19
+ },
20
+ "module": "./dist/index.mjs",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist"
24
+ ],
8
25
  "scripts": {
9
- "test": "echo \"Error: no test specified\" && exit 1"
26
+ "build": "tsup & copyfiles --up 1 \"src/*.css\" dist"
10
27
  },
11
28
  "keywords": [
12
29
  "page",
@@ -15,13 +32,16 @@
15
32
  "ssr",
16
33
  "csr"
17
34
  ],
18
- "files": [
19
- "sw.js", "transition.js", "OverlayPreset.css", "KeyFramePreset.css"
20
- ],
21
35
  "author": "Daniel Pagano",
22
36
  "license": "ISC",
23
37
  "repository": {
24
38
  "type": "git",
25
39
  "url": "https://github.com/danielpagano202/pagewave.git"
40
+ },
41
+ "devDependencies": {
42
+ "copyfiles": "^2.4.1",
43
+ "ts-node": "^10.9.2",
44
+ "tsup": "^8.5.1",
45
+ "typescript": "^5.9.3"
26
46
  }
27
47
  }
@@ -1,20 +0,0 @@
1
- @keyframes fade {
2
- from{
3
- opacity: 1;
4
- }
5
- to{
6
- opacity: 0;
7
- }
8
- }
9
- @keyframes fadeaway {
10
- from{
11
- position: absolute;
12
- opacity: 1;
13
- left: 0
14
- }
15
- to{
16
- position: absolute;
17
- opacity: 0;
18
- left: -200px
19
- }
20
- }
package/sw.js DELETED
@@ -1,40 +0,0 @@
1
- const CACHE_NAME = "Page Transition SW";
2
- let pageCache = [
3
- "transition.js",
4
- "OverlayPreset.css",
5
- "KeyFramePreset.css",
6
- ];
7
- self.addEventListener("fetch", (e) => {
8
- e.respondWith(
9
- caches.match(e.request).then(
10
- (response) => {
11
- if(response){
12
- return response;
13
- }
14
- return fetch(e.request);
15
- }
16
- )
17
- )
18
- });
19
- self.addEventListener("install", (e) => {
20
- e.waitUntil(
21
- caches.open(CACHE_NAME).then(
22
- (cache) => {return cache.addAll(pageCache);}
23
- )
24
- );
25
- });
26
- self.addEventListener('activate', function(event) {
27
- event.waitUntil(self.clients.claim()); // Become available to all pages
28
- });
29
- self.addEventListener("message", (event) => {
30
- fetch(event.data).then((response) => {
31
- if (!response.ok) {
32
- throw new TypeError("Bad response status");
33
- }
34
- caches.open(CACHE_NAME).then(
35
- (cache) => {return cache.put(event.data, response);}
36
- )
37
- });
38
-
39
-
40
- });
package/transition.js DELETED
@@ -1,518 +0,0 @@
1
- //Imports CSS Files from node_modules
2
- import * as kfp from "/node_modules/pagewave/KeyFramePreset.css";
3
- import * as op from "/node_modules/pagewave/OverlayPreset.css";
4
-
5
- //Default Options
6
- let defaultOptions = {
7
- mainContentIdName: "main-content",
8
- overlayClass: "a-overlay",
9
- animationClass: "a-animation",
10
- pageAnimationDelay: 200,
11
- useServiceWorker: true,
12
- runAnimationOnPageReload: false,
13
- runAnimationOnCrossSite: false,
14
- pageRevealDelay: 0,
15
- leavePageOnLink: true,
16
- pageBlockerId: "pageBlocker",
17
- classToIgnoreLink: "ignore-click",
18
- animateIgnoredLinks: false,
19
- animateSelfLink: true,
20
- loadEvent: "DOMContentLoaded",
21
- usePresets: true,
22
- cleanUpDivs: false,
23
- }
24
- //Options object that will contain the actual options used by the program
25
- let finalOptions = {
26
- mainContentIdName: "main-content",
27
- overlayClass: "a-overlay",
28
- animationClass: "a-animation",
29
- pageAnimationDelay: 200,
30
- useServiceWorker: true,
31
- runAnimationOnPageReload: false,
32
- runAnimationOnCrossSite: false,
33
- pageRevealDelay: 0,
34
- leavePageOnClick: true,
35
- pageBlockerId: "pageBlocker",
36
- classToIgnoreLink: "ignore-click",
37
- animateIgnoredLinks: false,
38
- animateSelfLink: true,
39
- loadEvent: "DOMContentLoaded",
40
- usePresets: true,
41
- cleanUpDivs: false,
42
- }
43
-
44
- //Sets Up Page Transition Capability. Not necessary if you don't need options or presets
45
- function SetUp(options = {}) {
46
- //Merge default options with user options
47
- finalOptions = { ...defaultOptions, ...options };
48
- //Import css files into HTML document automatically
49
- if(finalOptions.usePresets){
50
- let cssFiles = ["OverlayPreset.css", "KeyFramePreset.css"];
51
- for (let i = 0; i < cssFiles.length; i++) {
52
- let link = document.createElement('link');
53
- link.rel = 'stylesheet';
54
- link.type = 'text/css';
55
- link.href = cssFiles[i];
56
- document.getElementsByTagName('HEAD')[0].appendChild(link);
57
- }
58
- }
59
- }
60
- const _SetUp = SetUp;
61
- export { _SetUp as SetUp };
62
- //Overlay Preset Types to Choose From
63
- const overlayType = Object.freeze({
64
- slide: Symbol("slide"),
65
- inverseSlide: Symbol("inverseSlide"),
66
- curtain: Symbol("curtain"),
67
- rise: Symbol("rise"),
68
- fall: Symbol("fall"),
69
- bubble: Symbol("bubble"),
70
- });
71
- const _overlayType = overlayType;
72
- export { _overlayType as overlayType };
73
- //Keyframe Preset Types to Choose From
74
- const keyframeType = Object.freeze({
75
- fade: Symbol("fade"),
76
- fadeaway: Symbol("fadeaway"),
77
- });
78
- const _keyframeType = keyframeType;
79
- export { _keyframeType as keyframeType };
80
-
81
- //Function to apply animation to element and keep its properties and remove the animation
82
- function ApplyAnimation(element, animationName, duration, timing, direction) {
83
- element.style.animation = `${animationName} ${duration}ms ${timing} both ${direction}`;
84
- if (direction == "reverse") {
85
- let currentAnimation = null;
86
- element.getAnimations().forEach((animation) => {
87
- if (currentAnimation == null && animation.animationName == animationName) {
88
- currentAnimation = animation;
89
- }
90
- });
91
- function handleAnimation(event) {
92
- if (event.animationName == animationName) {
93
- let animationKeyframes = currentAnimation.effect;
94
- let kfValues = Object.values(animationKeyframes.getKeyframes()[0]);
95
- let kfKeys = Object.keys(animationKeyframes.getKeyframes()[0]);
96
- let animationProperties = kfValues.slice(3, kfValues.length - 1);
97
- let animationKeys = kfKeys.slice(3, kfValues.length - 1);
98
- for (let i = 0; i < animationKeys.length; i++) {
99
- element.style[animationKeys[i]] = animationProperties[i].toString();
100
- }
101
- element.style.animation = "";
102
- element.removeEventListener("animationend", handleAnimation);
103
- }
104
- }
105
- element.addEventListener("animationend", handleAnimation,);
106
- }
107
- }
108
- //Dispatch an event for the hooks
109
- function CallHook(hookName, details) {
110
- const event = new CustomEvent(hookName, {
111
- detail: details
112
- });
113
- window.dispatchEvent(event);
114
- }
115
-
116
- class KeyFramePreset {
117
- constructor(kfType, duration, timing = "linear") {
118
- this.kfType = kfType;
119
- this.duration = duration;
120
- this.timing = timing;
121
- }
122
- handle(direction) {
123
- const animationMap = {
124
- fade: "fade",
125
- fadeaway: "fadeaway"
126
- };
127
- //Uses keyframeType to run Keyframe Custom
128
- if (animationMap[this.kfType.description]) {
129
- AnimatePageTransition(new KeyFrameCustom(animationMap[this.kfType.description], this.duration, this.timing), direction);
130
- }
131
- }
132
- }
133
- const _KeyFramePreset = KeyFramePreset;
134
- export { _KeyFramePreset as KeyFramePreset };
135
- class KeyFrameCustom {
136
- constructor(animationName, duration, timing = "linear") {
137
- this.animationName = animationName;
138
- this.duration = duration;
139
- this.timing = timing;
140
- }
141
- handle(direction, mainElement) {
142
- //Reveals element and applys the animation
143
- mainElement.hidden = false;
144
- ApplyAnimation(mainElement, this.animationName, this.duration, this.timing, direction)
145
- }
146
- }
147
- const _KeyFrameCustom = KeyFrameCustom;
148
- export { _KeyFrameCustom as KeyFrameCustom };
149
- class StyleTransition {
150
- constructor(styleString, duration, startValue, endValue, timing = "linear") {
151
- this.styleString = styleString;
152
- this.duration = duration;
153
- this.startValue = startValue
154
- this.endValue = endValue;
155
- this.timing = timing;
156
- }
157
- handle(direction, mainElement) {
158
- //Applys the transition in the right direction
159
- if (direction == "normal") {
160
- mainElement.style[this.styleString] = this.startValue;
161
- mainElement.style.transition = this.styleString + " " + this.duration.toString() + "ms " + this.timing;
162
- mainElement.style[this.styleString] = this.endValue;
163
- } else if (direction == "reverse") {
164
- mainElement.style[this.styleString] = this.endValue;
165
- mainElement.style.transition = this.styleString + " " + this.duration.toString() + "ms " + this.timing;
166
- //Timeout is needed for some reason. Need to test further but it works
167
- setTimeout(
168
- () => {
169
- mainElement.style[this.styleString] = this.startValue;
170
- }, 40
171
- );
172
-
173
- }
174
- }
175
- }
176
- const _StyleTransition = StyleTransition;
177
- export { _StyleTransition as StyleTransition };
178
- class MultiElementAnimation {
179
- constructor(animateableObjects, duration, timing = "linear", mainElementAnimation = "") {
180
- this.animateableObjects = animateableObjects;
181
- this.duration = duration;
182
- this.timing = timing;
183
- this.mainElementAnimation = mainElementAnimation;
184
- }
185
- handle(direction, mainElement) {
186
- mainElement.hidden = false;
187
- let timing = this.timing;
188
- //Goes through every animation selector, finds all of those elements, and applies the proper animation to them
189
- for (const [selector, animationName] of Object.entries(this.animateableObjects)) {
190
- document.querySelectorAll(selector).forEach(element => ApplyAnimation(element, animationName, this.duration, timing, direction));
191
- }
192
- //Animates main element if animation is given
193
- if (this.mainElementAnimation != "") {
194
- ApplyAnimation(mainElement, this.mainElementAnimation, this.duration, timing, direction);
195
- }
196
- }
197
- }
198
- const _MultiElementAnimation = MultiElementAnimation;
199
- export { _MultiElementAnimation as MultiElementAnimation };
200
- class OverlayPreset {
201
- constructor(oType, duration, color, timing = "linear") {
202
- this.duration = duration;
203
- this.color = color;
204
- this.oType = oType;
205
- this.timing = timing;
206
- }
207
- handle(direction) {
208
- //Finds the proper preset and runs OverlayCustom appropriately
209
- const overlayMap = {
210
- slide: { firstOverlayElement: "slide" },
211
- inverseSlide: { firstOverlayElement: "inverseSlide" },
212
- curtain: { firstOverlayElement: "rightcurtain", secondOverlayElement: "leftcurtain" },
213
- rise: { firstOverlayElement: "rise" },
214
- fall: { firstOverlayElement: "fall" },
215
- bubble: { firstOverlayElement: "bubble" }
216
- };
217
- if (overlayMap[this.oType.description]) {
218
- AnimatePageTransition(new OverlayCustom(overlayMap[this.oType.description], this.duration, this.color, this.timing), direction);
219
- }
220
- }
221
- }
222
- const _OverlayPreset = OverlayPreset;
223
- export { _OverlayPreset as OverlayPreset };
224
- class OverlayCustom {
225
- constructor(divAnimationObject, duration, color, timing = "linear", mainElementAnimation = "") {
226
- this.divAnimationObject = divAnimationObject;
227
- this.duration = duration;
228
- this.color = color;
229
- this.timing = timing;
230
- this.mainElementAnimation = mainElementAnimation;
231
- }
232
- handle(direction, mainElement) {
233
- var r = document.querySelector(':root');
234
- r.style.setProperty('--div-color', this.color);
235
- let timing = this.timing;
236
- //Removes divs when animation is finished
237
- function RemoveDiv(event) {
238
- if (event.target.animateName == event.animationName) {
239
- event.target.removeEventListener("animationend", RemoveDiv);
240
- event.target.remove();
241
- }
242
- }
243
- //Loops through divs, creating them, adding the provided class, and giving them an animation
244
- for (const [className, animationName] of Object.entries(this.divAnimationObject)) {
245
- let divElement = document.createElement("div");
246
- divElement.className = className;
247
- divElement.style.animation = `${animationName} ${this.duration.toString()}ms ${timing} both ${direction}`;
248
- mainElement.appendChild(divElement);
249
- //Removes divs at end of animation
250
- if(finalOptions.cleanUpDivs){
251
- divElement.animateName = animationName;
252
- divElement.addEventListener("animationend", RemoveDiv);
253
- }
254
- }
255
- //Animates main element if animation is given
256
- if (this.mainElementAnimation != "") {
257
- mainElement.style.animation = `${this.mainElementAnimation} ${this.duration.toString()}ms ${timing} both ${direction}`;
258
- }
259
- }
260
- }
261
- const _OverlayCustom = OverlayCustom;
262
- export { _OverlayCustom as OverlayCustom };
263
- /*
264
- function AddFileToCache(file) {
265
- if ("serviceWorker" in navigator) {
266
- if (navigator.serviceWorker.controller) {
267
- if (navigator.serviceWorker.controller.scriptURL.slice(-5) == "sw.js") {
268
- navigator.serviceWorker.controller.postMessage(file);
269
- }
270
- }
271
- }
272
- }*/
273
- //Adds service worker to cache presets and this script. Returns a boolean true if it is already active or useServiceWorker was overrided; false otherwise
274
- function AddServiceWorker() {
275
- if (!finalOptions.useServiceWorker) {
276
- return true;
277
- }
278
- let isServiceWorker = false;
279
- if ("serviceWorker" in navigator) {
280
- if (navigator.serviceWorker.controller) {
281
- if (navigator.serviceWorker.controller.scriptURL.slice(-5) == "sw.js") {
282
- isServiceWorker = true;
283
- }
284
- }
285
- navigator.serviceWorker.register("./node_modules/pagewave/sw.js");
286
- }
287
- return isServiceWorker;
288
- }
289
- //Checks if navigation is from same site. Returns false if referrer and current host are different of refferer is empty
290
- function isNavigationFromSameSite() {
291
- const referrer = document.referrer;
292
- if (referrer == "") {
293
- return false;
294
- }
295
- const currentHost = window.location.hostname;
296
- const referrerHost = new URL(referrer).hostname;
297
-
298
- return referrerHost === currentHost;
299
- }
300
- //Returns true if animation is overlay type, false if animation type
301
- function IsOverlay(transitionStyle) {
302
- if (transitionStyle instanceof OverlayPreset || transitionStyle instanceof OverlayCustom) {
303
- return true;
304
- } else if (transitionStyle instanceof StyleTransition || transitionStyle instanceof KeyFrameCustom || transitionStyle instanceof KeyFramePreset || transitionStyle instanceof MultiElementAnimation) {
305
- return false;
306
- }
307
- }
308
- const _IsOverlay = IsOverlay;
309
- export { _IsOverlay as IsOverlay };
310
- //Checks if element exists. If it does, it runs functionToExecute. Otherwise, waits until element exists to run the function
311
- function WaitForElementLoad(selector, functionToExecute) {
312
- if(document.querySelector(selector) != null){
313
- functionToExecute(document.querySelector(selector));
314
- return;
315
- }
316
- const observer = new MutationObserver((mutations) => {
317
- mutations.forEach((mutation) => {
318
- mutation.addedNodes.forEach((node) => {
319
- if (node.matches && node.matches(selector)) {
320
- observer.disconnect(); // Stop observing
321
- functionToExecute(node); // Handle the element
322
- }
323
- });
324
- });
325
- });
326
- // Start observing the document body for child additions
327
- observer.observe(document.body, { childList: true, subtree: true });
328
- }
329
- const _WaitForElementLoad = WaitForElementLoad;
330
- export { _WaitForElementLoad as WaitForElementLoad };
331
- //Shorthand for SendPoint and EndPoint
332
- function ListenForChange(aStyle, aOverlay = aStyle, aAnimation = aStyle, leaveFunction = (link) => {window.location = link;}) {
333
- EndPoint(aStyle, aOverlay, aAnimation, leaveFunction);
334
- SendPoint(aStyle, aOverlay, aAnimation);
335
- }
336
- const _ListenForChange = ListenForChange;
337
- export { _ListenForChange as ListenForChange };
338
- //Listens for clicks and plays animation and then redirects
339
- function SendPoint(aStyle, aOverlay = aStyle, aAnimation = aStyle, leaveFunction = (link) => {window.location = link;}) {
340
- //True if service worker is active or ignored with useServiceWorker=false, false otherwise
341
- let allowAnimate = AddServiceWorker();
342
-
343
- function HandleClickAnimation(e) {
344
- //Checks to see if target is a link, it is not a link to ignore, not a self link + animateSelfLink=false
345
- if (e.target.tagName == "A" && !(e.target.classList.contains(finalOptions.classToIgnoreLink)) && !(e.target.href == window.location.href && !finalOptions.animateSelfLink)) {
346
- //Prevents link from redirecting
347
- e.preventDefault();
348
- let duration = aStyle.duration;
349
- CallHook("animateSSP", { style: aStyle, overlayStyle: aOverlay, animationStyle: aAnimation, clickEvent: e });
350
- //Plays the right animation depending on link type and sets proper duration
351
- if (e.target.classList.contains(finalOptions.overlayClass)) {
352
- AnimatePageTransition(aOverlay, "normal");
353
- duration = aOverlay.duration;
354
- } else if (e.target.classList.contains(finalOptions.animationClass)) {
355
- AnimatePageTransition(aAnimation, "normal");
356
- duration = aAnimation.duration;
357
- } else {
358
- AnimatePageTransition(aStyle, "normal");
359
- duration = aStyle.duration;
360
- }
361
- //Calls the leave function when duration timer finishes
362
- setTimeout(
363
- () => {
364
- CallHook("animateESP", { style: aStyle, overlayStyle: aOverlay, animationStyle: aAnimation, clickEvent: e });
365
- window.removeEventListener("click", HandleClickAnimation);
366
- if (finalOptions.leavePageOnClick) {
367
- leaveFunction(e.target.href);
368
- }
369
- }, parseInt(duration)
370
- );
371
- //We set the storage to ignore so we don't play an animation when we go to another page.
372
- } else if (e.target.classList.contains(finalOptions.classToIgnoreLink) || (e.target.href == window.location.href && !finalOptions.animateSelfLink)) {
373
- sessionStorage.setItem("animationType", "ignore");
374
- }
375
-
376
- }
377
-
378
- function AddListeners() {
379
- window.addEventListener("click", HandleClickAnimation);
380
- }
381
- //If service worker active, can immediately listen
382
- if (allowAnimate) {
383
- AddListeners();
384
- }
385
- //Else, wait until the loadEvent provided is triggered
386
- else {
387
- window.addEventListener(finalOptions.loadEvent, () => {
388
- AddListeners();
389
- }, { once: true });
390
- }
391
- }
392
- const _SendPoint = SendPoint;
393
- export { _SendPoint as SendPoint };
394
- //Waits for the document to load and plays the reverse animation
395
- function EndPoint(aStyle, aOverlay = aStyle, aAnimation = aStyle) {
396
- //Checks to see what kind of receiving animation to play
397
- if (aOverlay != aStyle || aAnimation != aStyle) {
398
- if (sessionStorage.getItem("animationType") === "true") {
399
- aStyle = aOverlay;
400
- } else if (sessionStorage.getItem("animationType") === "false") {
401
- aStyle = aAnimation;
402
- }
403
- }
404
- function RevealPage(opposite = false) {
405
- if (Boolean(IsOverlay(aStyle) ^ opposite)) {
406
- if (document.getElementById(finalOptions.pageBlockerId) == null) {
407
- WaitForElementLoad(
408
- "#" + finalOptions.pageBlockerId, () => {
409
- if (document.getElementById(finalOptions.pageBlockerId) != null) {
410
- document.getElementById(finalOptions.pageBlockerId).remove();
411
- }
412
- }
413
- );
414
- } else {
415
- document.getElementById(finalOptions.pageBlockerId).remove();
416
- }
417
- }
418
- else if(Boolean(!IsOverlay(aStyle) ^ opposite)) {
419
- if (document.getElementById(finalOptions.mainContentIdName) == null) {
420
- WaitForElementLoad(
421
- "#" + finalOptions.mainContentIdName, () => {
422
- document.getElementById(finalOptions.mainContentIdName).hidden = false;
423
- }
424
- );
425
- } else {
426
- document.getElementById(finalOptions.mainContentIdName).hidden = false;
427
- }
428
- }
429
- }
430
- //True if service worker is active or ignored with useServiceWorker=false, false otherwise
431
- let allowAnimate = AddServiceWorker();
432
- //Figures out what kind of animation it is and hides the document properly
433
- if (IsOverlay(aStyle)) {
434
- RevealPage(true);
435
- let pageBlocker = document.createElement('div');
436
- pageBlocker.id = finalOptions.pageBlockerId;
437
- pageBlocker.style.cssText = `position: absolute; width: 100%; height: 100%; z-index: 100; top: 0; background-color: ${aStyle.color}`
438
- document.body.append(pageBlocker);
439
- } else {
440
- RevealPage(true);
441
- if (document.getElementById(finalOptions.mainContentIdName) == null) {
442
- WaitForElementLoad(
443
- "#" + finalOptions.mainContentIdName, () => {
444
- document.getElementById(finalOptions.mainContentIdName).hidden = true;
445
- }
446
- );
447
- } else {
448
- document.getElementById(finalOptions.mainContentIdName).hidden = true;
449
- }
450
- }
451
- //Checks to see if allowAnimate=true and we aren't supposed to be ignoring the link
452
- if (allowAnimate && !(sessionStorage.getItem("animationType") === "ignore" && (finalOptions.animateIgnoredLinks || finalOptions.animateSelfLink))){
453
- //Once the load evnet is triggered, it registers a listener
454
- window.addEventListener(finalOptions.loadEvent, (e) => {
455
- e.stopPropagation();
456
- CallHook("animateSEP", { style: aStyle });
457
- //If we reloaded, we want to make sure runAnimationOnPageReload is false and if we came from a different site, we want to make sure we can run animation on cross site
458
- if ((window.performance.getEntriesByType("navigation")[0].type != "reload" || finalOptions.runAnimationOnPageReload) && (isNavigationFromSameSite() || finalOptions.runAnimationOnCrossSite)) {
459
- //Uses a delay between this to keep the document hidden for extra if the load event isn't trusted
460
- setTimeout(
461
- () => {
462
- AnimatePageTransition(aStyle, "reverse");
463
- //Delay between animation and reveal
464
- setTimeout(
465
- () => {
466
- CallHook("animateEEP", { style: aStyle });
467
- RevealPage();
468
- }, finalOptions.pageRevealDelay
469
- );
470
- }, finalOptions.pageAnimationDelay
471
- );
472
- } else {
473
- //Reveals page after document is built
474
- CallHook("animateEPNA", { style: aStyle })
475
- RevealPage();
476
- }
477
- }, { once: true });
478
- } else {
479
- //Waits for load and Reveals the Page
480
- window.addEventListener(finalOptions.loadEvent, () => {
481
- CallHook("animateEPNSW", { style: aStyle })
482
- RevealPage();
483
- }, { once: true });
484
- }
485
- }
486
- const _EndPoint = EndPoint;
487
- export { _EndPoint as EndPoint };
488
- //Animates the page transition
489
- function AnimatePageTransition(aStyle, direction = "normal") {
490
- let mainElement = document.getElementById(finalOptions.mainContentIdName);
491
- //If we don't have a preset, we can call a hook because presets also call their custom variant
492
- if (!(aStyle instanceof OverlayPreset) && !(aStyle instanceof KeyFramePreset)) {
493
- //Sets animationType in storage to allow EndPoint to change page transition element depending on type
494
- sessionStorage.setItem("animationType", IsOverlay(aStyle).toString());
495
- if (direction == "normal") {
496
- CallHook("animateSF", { style: aStyle, ele: mainElement, });
497
- } else if (direction == "reverse") {
498
- CallHook("animateSR", { style: aStyle, ele: mainElement, });
499
- }
500
- }
501
- //Calls handle function of style element
502
- aStyle.handle(direction, mainElement);
503
- //Same logic as above except for end hooks
504
- if (!(aStyle instanceof OverlayPreset) && !(aStyle instanceof KeyFramePreset)) {
505
- setTimeout(
506
- () => {
507
- if (direction == "normal") {
508
- CallHook("animateEF", { style: aStyle, ele: mainElement, });
509
- } else if (direction == "reverse") {
510
- CallHook("animateER", { style: aStyle, ele: mainElement, });
511
- }
512
- }, aStyle.duration
513
- );
514
- }
515
-
516
- }
517
- const _AnimatePageTransition = AnimatePageTransition;
518
- export { _AnimatePageTransition as AnimatePageTransition };