@hortonstudio/main 1.9.10 → 1.9.20

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 (124) hide show
  1. package/.prettierrc +8 -0
  2. package/README.md +146 -0
  3. package/eslint.config.js +32 -0
  4. package/index.ts +275 -0
  5. package/package.json +19 -2
  6. package/public/bootstrap.js +16 -0
  7. package/src/animations/animations.ts +93 -0
  8. package/src/animations/functions/counter/counter.ts +137 -0
  9. package/src/config.json +570 -0
  10. package/src/config.ts +105 -0
  11. package/src/modules/default/README.md +167 -0
  12. package/src/modules/default/default.ts +71 -0
  13. package/{autoInit → src/modules/default/functions}/accessibility/README.md +44 -12
  14. package/src/modules/default/functions/accessibility/accessibility.ts +54 -0
  15. package/src/modules/default/functions/accordion/README.md +451 -0
  16. package/src/modules/default/functions/accordion/accordion.ts +189 -0
  17. package/src/modules/default/functions/comparison/comparison.ts +424 -0
  18. package/src/modules/default/functions/marquee/marquee.ts +206 -0
  19. package/src/modules/default/functions/navbar/README.md +393 -0
  20. package/src/modules/default/functions/navbar/functions/arrow-navigation/arrow-navigation.ts +183 -0
  21. package/src/modules/default/functions/navbar/functions/dropdown/dropdown.ts +313 -0
  22. package/src/modules/default/functions/navbar/functions/menu/menu.ts +315 -0
  23. package/src/modules/default/functions/navbar/navbar.ts +51 -0
  24. package/{autoInit → src/modules/default/functions}/smooth-scroll/README.md +45 -14
  25. package/{autoInit/smooth-scroll/smooth-scroll.js → src/modules/default/functions/smooth-scroll/smooth-scroll.ts} +33 -38
  26. package/{autoInit → src/modules/default/functions}/transition/README.md +59 -32
  27. package/src/modules/default/functions/transition/transition.ts +290 -0
  28. package/src/modules/normalize/README.md +172 -0
  29. package/src/modules/normalize/functions/clickable/README.md +84 -0
  30. package/src/modules/normalize/functions/clickable/clickable.ts +43 -0
  31. package/src/modules/normalize/functions/clickable/functions/normalize/README.md +213 -0
  32. package/src/modules/normalize/functions/clickable/functions/normalize/normalize.ts +68 -0
  33. package/src/modules/normalize/functions/dupe/README.md +405 -0
  34. package/src/modules/normalize/functions/dupe/dupe.ts +197 -0
  35. package/src/modules/normalize/functions/sync/sync.ts +378 -0
  36. package/src/modules/normalize/normalize.ts +58 -0
  37. package/src/modules/structure/README.md +190 -0
  38. package/src/modules/structure/functions/form/README.md +94 -0
  39. package/src/modules/structure/functions/form/form.ts +54 -0
  40. package/src/modules/structure/functions/form/functions/honeypot/README.md +77 -0
  41. package/src/modules/structure/functions/form/functions/honeypot/honeypot.ts +37 -0
  42. package/src/modules/structure/functions/form/functions/range/README.md +410 -0
  43. package/src/modules/structure/functions/form/functions/range/range.ts +92 -0
  44. package/src/modules/structure/functions/form/functions/select/README.md +393 -0
  45. package/src/modules/structure/functions/form/functions/select/functions/custom-select/custom-select.ts +637 -0
  46. package/src/modules/structure/functions/form/functions/select/functions/states/states.ts +118 -0
  47. package/src/modules/structure/functions/form/functions/select/select.ts +48 -0
  48. package/src/modules/structure/functions/form/functions/test/test.ts +132 -0
  49. package/src/modules/structure/functions/pagination/README.md +527 -0
  50. package/src/modules/structure/functions/pagination/pagination.ts +493 -0
  51. package/src/modules/structure/functions/site-settings/README.md +395 -0
  52. package/src/modules/structure/functions/site-settings/site-settings.ts +158 -0
  53. package/{autoInit/accessibility → src/modules/structure}/functions/toc/README.md +18 -15
  54. package/{autoInit/accessibility/functions/toc/toc.js → src/modules/structure/functions/toc/functions/heading-links/heading-links.ts} +43 -63
  55. package/src/modules/structure/functions/toc/functions/progress-bar/progress-bar.ts +101 -0
  56. package/src/modules/structure/functions/toc/toc.ts +35 -0
  57. package/{autoInit/accessibility → src/modules/structure}/functions/year-replacement/README.md +7 -6
  58. package/src/modules/structure/functions/year-replacement/year-replacement.ts +59 -0
  59. package/src/modules/structure/structure.ts +59 -0
  60. package/src/utils/attributeSelector.ts +78 -0
  61. package/src/utils/cssVariables.ts +24 -0
  62. package/src/utils/gsap.ts +198 -0
  63. package/src/utils/heightAnimator.ts +130 -0
  64. package/src/utils/modalManager.ts +150 -0
  65. package/src/utils.ts +54 -0
  66. package/tsconfig.json +24 -0
  67. package/vite.config.js +45 -0
  68. package/.claude/settings.local.json +0 -70
  69. package/archive/hero.js +0 -794
  70. package/archive/modal.js +0 -80
  71. package/archive/text.js +0 -628
  72. package/autoInit/accessibility/accessibility.js +0 -53
  73. package/autoInit/accessibility/functions/blog-remover/README.md +0 -61
  74. package/autoInit/accessibility/functions/blog-remover/blog-remover.js +0 -31
  75. package/autoInit/accessibility/functions/click-forwarding/README.md +0 -60
  76. package/autoInit/accessibility/functions/click-forwarding/click-forwarding.js +0 -82
  77. package/autoInit/accessibility/functions/dropdown/README.md +0 -212
  78. package/autoInit/accessibility/functions/dropdown/dropdown.js +0 -167
  79. package/autoInit/accessibility/functions/list-accessibility/README.md +0 -56
  80. package/autoInit/accessibility/functions/list-accessibility/list-accessibility.js +0 -23
  81. package/autoInit/accessibility/functions/pagination/README.md +0 -428
  82. package/autoInit/accessibility/functions/pagination/pagination.js +0 -359
  83. package/autoInit/accessibility/functions/text-synchronization/README.md +0 -62
  84. package/autoInit/accessibility/functions/text-synchronization/text-synchronization.js +0 -101
  85. package/autoInit/accessibility/functions/year-replacement/year-replacement.js +0 -43
  86. package/autoInit/button/README.md +0 -122
  87. package/autoInit/button/button.js +0 -51
  88. package/autoInit/counter/README.md +0 -274
  89. package/autoInit/counter/counter.js +0 -185
  90. package/autoInit/form/README.md +0 -338
  91. package/autoInit/form/form.js +0 -374
  92. package/autoInit/navbar/README.md +0 -366
  93. package/autoInit/navbar/navbar.js +0 -786
  94. package/autoInit/site-settings/README.md +0 -218
  95. package/autoInit/site-settings/site-settings.js +0 -134
  96. package/autoInit/transition/transition.js +0 -116
  97. package/index.js +0 -305
  98. package/utils/before-after/README.md +0 -520
  99. package/utils/before-after/before-after.js +0 -653
  100. package/utils/css-animations/buttons/main/bgbasic/btn-main-bgbasic.html +0 -10
  101. package/utils/css-animations/buttons/main/bgfill/btn-main-bgfill.html +0 -29
  102. package/utils/css-animations/buttons/navbar/bgbasic/navbar-main-bgbasic.html +0 -17
  103. package/utils/css-animations/buttons/navbar/bgbasic/navbar-menu-bgbasic.html +0 -16
  104. package/utils/css-animations/buttons/navbar/bgfill/navbar-main-bgfill.html +0 -46
  105. package/utils/css-animations/buttons/navbar/bgfill/navbar-menu-bgfill.html +0 -39
  106. package/utils/css-animations/buttons/navbar/color/navbar-announce-color.html +0 -5
  107. package/utils/css-animations/buttons/navbar/color/navbar-main-color.html +0 -7
  108. package/utils/css-animations/buttons/navbar/color/navbar-menu-color.html +0 -7
  109. package/utils/css-animations/buttons/navbar/double-slide/navbar-announce-double-slide.html +0 -40
  110. package/utils/css-animations/buttons/navbar/double-slide/navbar-main-double-slide.html +0 -77
  111. package/utils/css-animations/buttons/navbar/scale/navbar-announce-scale.html +0 -6
  112. package/utils/css-animations/buttons/navbar/scale/navbar-main-scale.html +0 -9
  113. package/utils/css-animations/buttons/navbar/scale/navbar-menu-scale.html +0 -8
  114. package/utils/css-animations/buttons/navbar/underline/navbar-announce-underline.html +0 -32
  115. package/utils/css-animations/buttons/navbar/underline/navbar-main-underline.html +0 -56
  116. package/utils/css-animations/buttons/text/color/text-footer-color.html +0 -5
  117. package/utils/css-animations/buttons/text/color/text-main-color.html +0 -5
  118. package/utils/css-animations/buttons/text/double-slide/text-main-double-slide.html +0 -56
  119. package/utils/css-animations/buttons/text/scale/text-footer-scale.html +0 -6
  120. package/utils/css-animations/buttons/text/scale/text-main-scale.html +0 -6
  121. package/utils/css-animations/buttons/text/underline/text-footer-underline.html +0 -45
  122. package/utils/css-animations/buttons/text/underline/text-main-underline.html +0 -58
  123. package/utils/css-animations/cards/card-clickable.html +0 -11
  124. package/utils/css-animations/defaults.html +0 -69
package/archive/hero.js DELETED
@@ -1,794 +0,0 @@
1
- const API_NAME = "hsmain";
2
-
3
- // Check for reduced motion preference
4
- const prefersReducedMotion = () => {
5
- return (
6
- window.matchMedia &&
7
- window.matchMedia("(prefers-reduced-motion: reduce)").matches
8
- );
9
- };
10
-
11
- // Animation timing (in seconds)
12
- const timing = {
13
- announce: 0,
14
- nav: 0.1,
15
- navLogo: 0.3,
16
- navList: 0.35,
17
- navMenu: 0.35,
18
- navButton: 0.5,
19
- tag: 0.1,
20
- heading: 0.15,
21
- subheading: 0.25,
22
- button: 0.35,
23
- image: 0.5,
24
- appear: 0.6,
25
- };
26
-
27
- // Hero Animations Module
28
- let heroTimeline = null;
29
- let headingSplits = [];
30
- let subheadingSplits = [];
31
- let heroTimeout = null; // Track the setTimeout
32
-
33
- const config = {
34
- global: {
35
- animationDelay: 0.2,
36
- },
37
- headingSplit: {
38
- duration: 1.5,
39
- stagger: 0.1,
40
- yPercent: 110,
41
- ease: "power4.out",
42
- },
43
- subheadingSplit: {
44
- duration: 1.5,
45
- stagger: 0.1,
46
- yPercent: 110,
47
- ease: "power4.out",
48
- },
49
- appear: {
50
- y: 50,
51
- duration: 1,
52
- ease: "power3.out",
53
- },
54
- navStagger: {
55
- duration: 1,
56
- stagger: 0.1,
57
- ease: "power3.out",
58
- },
59
- nav: {
60
- duration: 1,
61
- ease: "power3.out",
62
- },
63
- };
64
-
65
- function updateConfig(newConfig) {
66
- function deepMerge(target, source) {
67
- for (const key in source) {
68
- if (
69
- source[key] &&
70
- typeof source[key] === "object" &&
71
- !Array.isArray(source[key])
72
- ) {
73
- target[key] = target[key] || {};
74
- deepMerge(target[key], source[key]);
75
- } else {
76
- target[key] = source[key];
77
- }
78
- }
79
- return target;
80
- }
81
-
82
- deepMerge(config, newConfig);
83
- }
84
-
85
- function killHeroAnimations() {
86
- if (heroTimeout) {
87
- clearTimeout(heroTimeout);
88
- heroTimeout = null;
89
- }
90
-
91
- if (heroTimeline) {
92
- heroTimeline.kill();
93
- heroTimeline = null;
94
- }
95
-
96
- headingSplits.forEach((split) => {
97
- if (split && split.revert) {
98
- split.revert();
99
- }
100
- });
101
- headingSplits = [];
102
-
103
- subheadingSplits.forEach((split) => {
104
- if (split && split.revert) {
105
- split.revert();
106
- }
107
- });
108
- subheadingSplits = [];
109
-
110
- // Restore page-wide tabbing if animation is killed
111
- const allFocusableElements = document.querySelectorAll(
112
- "[data-original-tabindex]",
113
- );
114
- allFocusableElements.forEach((el) => {
115
- el.style.pointerEvents = "";
116
- const originalTabindex = el.getAttribute("data-original-tabindex");
117
- if (originalTabindex === "0") {
118
- el.removeAttribute("tabindex");
119
- } else {
120
- el.setAttribute("tabindex", originalTabindex);
121
- }
122
- el.removeAttribute("data-original-tabindex");
123
- });
124
- // Restore nav pointer events if animation is killed
125
- const navElement = document.querySelector('[data-hs-hero="nav"]');
126
- if (navElement) {
127
- navElement.style.pointerEvents = "";
128
- }
129
- }
130
-
131
- function startHeroAnimations() {
132
- killHeroAnimations();
133
- init();
134
- }
135
-
136
- function showHeroElementsWithoutAnimation() {
137
- // Simply show all hero elements without any animation or split text
138
- const allHeroElements = [
139
- ...document.querySelectorAll('[data-hs-hero="announce"]'),
140
- ...document.querySelectorAll('[data-hs-hero="nav"]'),
141
- ...document.querySelectorAll('[data-hs-hero="nav-menu"]'),
142
- ...document.querySelectorAll('[data-hs-hero="nav-logo"]'),
143
- ...document.querySelectorAll('[data-hs-hero="nav-button"] > *:first-child'),
144
- ...document.querySelectorAll(
145
- '[data-hs-hero="nav-list"] > * > *:first-child',
146
- ),
147
- ...document.querySelectorAll('[data-hs-hero="heading"] > *:first-child'),
148
- ...document.querySelectorAll('[data-hs-hero="subheading"] > *:first-child'),
149
- ...document.querySelectorAll('[data-hs-hero="tag"] > *:first-child'),
150
- ...document.querySelectorAll('[data-hs-hero="button"] > *'),
151
- ...document.querySelectorAll('[data-hs-hero="image"]'),
152
- ...document.querySelectorAll('[data-hs-hero="appear"]'),
153
- ...document.querySelectorAll('[data-hs-hero="main"]'),
154
- ];
155
-
156
- allHeroElements.forEach((element) => {
157
- if (element) {
158
- gsap.set(element, {
159
- autoAlpha: 1,
160
- opacity: 1,
161
- y: 0,
162
- yPercent: 0,
163
- });
164
- // Remove any pointer-events restrictions
165
- element.style.pointerEvents = "";
166
- }
167
- });
168
-
169
- // Restore page-wide tabbing
170
- const allFocusableElements = document.querySelectorAll(
171
- "[data-original-tabindex]",
172
- );
173
- allFocusableElements.forEach((el) => {
174
- el.style.pointerEvents = "";
175
- const originalTabindex = el.getAttribute("data-original-tabindex");
176
- if (originalTabindex === "0") {
177
- el.removeAttribute("tabindex");
178
- } else {
179
- el.setAttribute("tabindex", originalTabindex);
180
- }
181
- el.removeAttribute("data-original-tabindex");
182
- });
183
- }
184
-
185
- export async function init() {
186
- if (typeof window.gsap === "undefined") {
187
- console.error("GSAP not found - hero animations disabled");
188
- return;
189
- }
190
-
191
- if (prefersReducedMotion()) {
192
- // For reduced motion, just show elements without animation
193
- showHeroElementsWithoutAnimation();
194
-
195
- // Still expose the API for consistency
196
- window[API_NAME] = window[API_NAME] || {};
197
- window[API_NAME].heroAnimations = {
198
- config: config,
199
- updateConfig: updateConfig,
200
- start: startHeroAnimations,
201
- kill: killHeroAnimations,
202
- restart: () => {
203
- killHeroAnimations();
204
- startHeroAnimations();
205
- },
206
- };
207
-
208
- return { result: "anim-hero initialized (reduced motion)" };
209
- }
210
-
211
- gsap.registerPlugin(ScrollTrigger, SplitText);
212
-
213
- // Element selection
214
- const announceElements = document.querySelectorAll(
215
- '[data-hs-hero="announce"]',
216
- );
217
- const navElement = document.querySelector('[data-hs-hero="nav"]');
218
- const navMenuElements = document.querySelectorAll(
219
- '[data-hs-hero="nav-menu"]',
220
- );
221
- const navLogoElements = document.querySelectorAll(
222
- '[data-hs-hero="nav-logo"]',
223
- );
224
- const imageElements = document.querySelectorAll('[data-hs-hero="image"]');
225
- const imageFirstElements = document.querySelectorAll('[data-hs-hero="image"][data-hs-timing="first"]');
226
- const imageRegularElements = document.querySelectorAll('[data-hs-hero="image"]:not([data-hs-timing="first"])');
227
- const appearElements = document.querySelectorAll('[data-hs-hero="appear"]');
228
- const mainElements = document.querySelectorAll('[data-hs-hero="main"]');
229
-
230
- // Check if nav has advanced config
231
- const hasAdvancedNav =
232
- navElement &&
233
- navElement.hasAttribute("data-hs-config") &&
234
- navElement.getAttribute("data-hs-config") === "advanced";
235
-
236
- // First child elements - only select if advanced nav is enabled
237
- const navButton = [];
238
- if (hasAdvancedNav) {
239
- const navButtonParents = document.querySelectorAll(
240
- '[data-hs-hero="nav-button"]',
241
- );
242
- navButtonParents.forEach((el) => {
243
- if (el.firstElementChild) navButton.push(el.firstElementChild);
244
- });
245
- }
246
-
247
- const subheading = [];
248
- const subheadingAppearElements = [];
249
- const subheadingElements = document.querySelectorAll(
250
- '[data-hs-hero="subheading"]',
251
- );
252
- const subheadingSplitElements = [];
253
-
254
- subheadingElements.forEach((el) => {
255
- if (el.firstElementChild) {
256
- // Get the heroconfig attribute to determine animation type (default to appear)
257
- const heroConfig = el.getAttribute("data-hs-config") || "appear";
258
-
259
- if (heroConfig === "appear") {
260
- subheadingAppearElements.push(el.firstElementChild);
261
- } else {
262
- subheading.push(el.firstElementChild);
263
- subheadingSplitElements.push(el);
264
- }
265
- }
266
- });
267
-
268
- const heading = [];
269
- const headingAppearElements = [];
270
- const headingElements = document.querySelectorAll('[data-hs-hero="heading"]');
271
- const headingSplitElements = [];
272
-
273
- headingElements.forEach((el) => {
274
- if (el.firstElementChild) {
275
- // Get the heroconfig attribute to determine animation type
276
- const heroConfig = el.getAttribute("data-hs-config") || "line"; // default to line if not specified
277
-
278
- if (heroConfig === "appear") {
279
- headingAppearElements.push(el.firstElementChild);
280
- } else {
281
- heading.push(el.firstElementChild);
282
- headingSplitElements.push(el);
283
- }
284
- }
285
- });
286
-
287
- const tag = [];
288
- const tagParents = document.querySelectorAll('[data-hs-hero="tag"]');
289
- tagParents.forEach((el) => {
290
- if (el.firstElementChild) tag.push(el.firstElementChild);
291
- });
292
-
293
- // All children elements
294
- const buttonAllChildren = [];
295
- const buttonParents = document.querySelectorAll('[data-hs-hero="button"]');
296
- buttonParents.forEach((el) => {
297
- const children = Array.from(el.children);
298
- buttonAllChildren.push(...children);
299
- });
300
-
301
- const navListAllChildren = [];
302
- if (hasAdvancedNav) {
303
- const navListParents = document.querySelectorAll(
304
- '[data-hs-hero="nav-list"]',
305
- );
306
- navListParents.forEach((el) => {
307
- const children = Array.from(el.children);
308
-
309
- // Add overflow clip class to each child and collect their first child for animation
310
- children.forEach((child) => {
311
- child.classList.add("u-overflow-clip");
312
- if (child.firstElementChild) {
313
- navListAllChildren.push(child.firstElementChild);
314
- }
315
- });
316
- });
317
- }
318
-
319
- // Initial states
320
- if (announceElements.length > 0)
321
- gsap.set(announceElements, { opacity: 0, y: -50 });
322
- if (navElement) {
323
- gsap.set(navElement, { opacity: 0, y: -50 });
324
- // Disable nav pointer events until animation completes
325
- navElement.style.pointerEvents = "none";
326
- }
327
- if (hasAdvancedNav && navListAllChildren.length > 0)
328
- gsap.set(navListAllChildren, { opacity: 0, yPercent: 110 });
329
- if (hasAdvancedNav && navMenuElements.length > 0)
330
- gsap.set(navMenuElements, { opacity: 0 });
331
- if (hasAdvancedNav && navButton.length > 0)
332
- gsap.set(navButton, { opacity: 0 });
333
- if (hasAdvancedNav && navLogoElements.length > 0)
334
- gsap.set(navLogoElements, { opacity: 0 });
335
- if (subheadingAppearElements.length > 0)
336
- gsap.set(subheadingAppearElements, { y: config.appear.y, opacity: 0 });
337
- if (tag.length > 0) gsap.set(tag, { y: config.appear.y, opacity: 0 });
338
- if (buttonAllChildren.length > 0)
339
- gsap.set(buttonAllChildren, { y: config.appear.y, opacity: 0 });
340
- if (imageElements.length > 0) gsap.set(imageElements, { opacity: 0 });
341
- if (mainElements.length > 0) gsap.set(mainElements, { opacity: 0 });
342
- if (appearElements.length > 0)
343
- gsap.set(appearElements, { y: config.appear.y, opacity: 0 });
344
- if (headingAppearElements.length > 0)
345
- gsap.set(headingAppearElements, { y: config.appear.y, opacity: 0 });
346
-
347
- // Disable page-wide tabbing and interactions until animation completes
348
- const allFocusableElements = document.querySelectorAll(
349
- 'a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])',
350
- );
351
- allFocusableElements.forEach((el) => {
352
- el.style.pointerEvents = "none";
353
- el.setAttribute(
354
- "data-original-tabindex",
355
- el.getAttribute("tabindex") || "0",
356
- );
357
- el.setAttribute("tabindex", "-1");
358
- });
359
-
360
- // Animation timeline
361
- document.fonts.ready.then(() => {
362
- // Split text setup (after fonts are loaded)
363
- headingSplits = [];
364
-
365
- if (heading.length > 0) {
366
- headingSplitElements.forEach((parent, index) => {
367
- const textElement = heading[index];
368
- const splitType = parent.getAttribute("data-hs-config") || "line";
369
-
370
- let splitConfig = {};
371
- let elementsClass = "";
372
-
373
- if (splitType === "char") {
374
- splitConfig = {
375
- type: "words,chars",
376
- mask: "chars",
377
- charsClass: "char",
378
- };
379
- elementsClass = "chars";
380
- } else if (splitType === "line") {
381
- splitConfig = {
382
- type: "lines",
383
- mask: "lines",
384
- linesClass: "line",
385
- };
386
- elementsClass = "lines";
387
- } else {
388
- splitConfig = {
389
- type: "words",
390
- mask: "words",
391
- wordsClass: "word",
392
- };
393
- elementsClass = "words";
394
- }
395
-
396
- const split = new SplitText(textElement, splitConfig);
397
- split.elementsClass = elementsClass;
398
- headingSplits.push(split);
399
-
400
- gsap.set(split[elementsClass], {
401
- yPercent: config.headingSplit.yPercent,
402
- });
403
- gsap.set(textElement, { autoAlpha: 1 });
404
- });
405
- }
406
-
407
- // Split text setup for subheadings
408
- if (subheading.length > 0) {
409
- subheadingSplitElements.forEach((parent, index) => {
410
- const textElement = subheading[index];
411
- const splitType = parent.getAttribute("data-hs-config") || "word";
412
-
413
- let splitConfig = {};
414
- let elementsClass = "";
415
-
416
- if (splitType === "char") {
417
- splitConfig = {
418
- type: "words,chars",
419
- mask: "chars",
420
- charsClass: "char",
421
- };
422
- elementsClass = "chars";
423
- } else if (splitType === "line") {
424
- splitConfig = {
425
- type: "lines",
426
- mask: "lines",
427
- linesClass: "line",
428
- };
429
- elementsClass = "lines";
430
- } else {
431
- splitConfig = {
432
- type: "words",
433
- mask: "words",
434
- wordsClass: "word",
435
- };
436
- elementsClass = "words";
437
- }
438
-
439
- const split = new SplitText(textElement, splitConfig);
440
- split.elementsClass = elementsClass;
441
- subheadingSplits.push(split);
442
-
443
- gsap.set(split[elementsClass], {
444
- yPercent: config.subheadingSplit.yPercent,
445
- });
446
- gsap.set(textElement, { autoAlpha: 1 });
447
- });
448
- }
449
-
450
- heroTimeout = setTimeout(() => {
451
- heroTimeline = gsap.timeline();
452
-
453
- if (announceElements.length > 0) {
454
- heroTimeline.to(
455
- announceElements,
456
- {
457
- opacity: 1,
458
- y: 0,
459
- duration: config.nav.duration,
460
- ease: config.nav.ease,
461
- },
462
- timing.announce,
463
- );
464
- }
465
-
466
- if (navElement) {
467
- heroTimeline.to(
468
- navElement,
469
- {
470
- opacity: 1,
471
- y: 0,
472
- duration: config.nav.duration,
473
- ease: config.nav.ease,
474
- onComplete: () => {
475
- // If no advanced nav, restore interactions here
476
- if (!hasAdvancedNav) {
477
- const allFocusableElements = document.querySelectorAll(
478
- "[data-original-tabindex]",
479
- );
480
- allFocusableElements.forEach((el) => {
481
- el.style.pointerEvents = "";
482
- const originalTabindex = el.getAttribute(
483
- "data-original-tabindex",
484
- );
485
- if (originalTabindex === "0") {
486
- el.removeAttribute("tabindex");
487
- } else {
488
- el.setAttribute("tabindex", originalTabindex);
489
- }
490
- el.removeAttribute("data-original-tabindex");
491
- });
492
- // Restore nav pointer events
493
- navElement.style.pointerEvents = "";
494
- }
495
- },
496
- },
497
- timing.nav,
498
- );
499
- }
500
-
501
- if (hasAdvancedNav && navLogoElements.length > 0) {
502
- heroTimeline.to(
503
- navLogoElements,
504
- { opacity: 1, duration: 0.5, ease: config.nav.ease },
505
- timing.navLogo,
506
- );
507
- }
508
-
509
- if (hasAdvancedNav && navListAllChildren.length > 0) {
510
- heroTimeline.to(
511
- navListAllChildren,
512
- {
513
- opacity: 1,
514
- yPercent: 0,
515
- duration: config.nav.duration,
516
- stagger: 0.05,
517
- ease: config.nav.ease,
518
- onComplete: () => {
519
- // Remove u-overflow-clip class from list children
520
- const navListParents = document.querySelectorAll(
521
- '[data-hs-hero="nav-list"]',
522
- );
523
- navListParents.forEach((parent) => {
524
- const children = parent.children;
525
- Array.from(children).forEach((child) => {
526
- child.classList.remove("u-overflow-clip");
527
- });
528
- });
529
- },
530
- },
531
- timing.navList,
532
- );
533
- }
534
-
535
- if (hasAdvancedNav && navMenuElements.length > 0) {
536
- heroTimeline.to(
537
- navMenuElements,
538
- { opacity: 1, duration: config.nav.duration, ease: config.nav.ease },
539
- timing.navMenu,
540
- );
541
- }
542
-
543
- if (hasAdvancedNav && navButton.length > 0) {
544
- heroTimeline.to(
545
- navButton,
546
- {
547
- opacity: 1,
548
- duration: config.nav.duration,
549
- ease: config.nav.ease,
550
- onComplete: () => {
551
- // Restore page-wide tabbing and interactions after navbar animations complete
552
- const allFocusableElements = document.querySelectorAll(
553
- "[data-original-tabindex]",
554
- );
555
- allFocusableElements.forEach((el) => {
556
- el.style.pointerEvents = "";
557
- const originalTabindex = el.getAttribute(
558
- "data-original-tabindex",
559
- );
560
- if (originalTabindex === "0") {
561
- el.removeAttribute("tabindex");
562
- } else {
563
- el.setAttribute("tabindex", originalTabindex);
564
- }
565
- el.removeAttribute("data-original-tabindex");
566
- });
567
- // Restore nav pointer events
568
- if (navElement) {
569
- navElement.style.pointerEvents = "";
570
- }
571
- },
572
- },
573
- timing.navButton,
574
- );
575
- }
576
-
577
- if (headingSplits.length > 0) {
578
- headingSplits.forEach((split) => {
579
- heroTimeline.to(
580
- split[split.elementsClass],
581
- {
582
- yPercent: 0,
583
- duration: config.headingSplit.duration,
584
- stagger: config.headingSplit.stagger,
585
- ease: config.headingSplit.ease,
586
- onComplete: () => {
587
- if (split && split.revert) {
588
- split.revert();
589
- }
590
- },
591
- },
592
- timing.heading,
593
- );
594
- });
595
- }
596
-
597
- if (subheadingSplits.length > 0) {
598
- subheadingSplits.forEach((split) => {
599
- heroTimeline.to(
600
- split[split.elementsClass],
601
- {
602
- yPercent: 0,
603
- duration: config.subheadingSplit.duration,
604
- stagger: config.subheadingSplit.stagger,
605
- ease: config.subheadingSplit.ease,
606
- onComplete: () => {
607
- if (split && split.revert) {
608
- split.revert();
609
- }
610
- },
611
- },
612
- timing.subheading,
613
- );
614
- });
615
- }
616
-
617
- if (subheadingAppearElements.length > 0) {
618
- heroTimeline.to(
619
- subheadingAppearElements,
620
- {
621
- y: 0,
622
- opacity: 1,
623
- duration: config.appear.duration,
624
- ease: config.appear.ease,
625
- },
626
- timing.subheading,
627
- );
628
- }
629
-
630
- if (tag.length > 0) {
631
- heroTimeline.to(
632
- tag,
633
- {
634
- y: 0,
635
- opacity: 1,
636
- duration: config.appear.duration,
637
- ease: config.appear.ease,
638
- },
639
- timing.tag,
640
- );
641
- }
642
-
643
- if (buttonAllChildren.length > 0) {
644
- heroTimeline.to(
645
- buttonAllChildren,
646
- {
647
- y: 0,
648
- opacity: 1,
649
- duration: config.navStagger.duration,
650
- stagger: config.navStagger.stagger,
651
- ease: config.navStagger.ease,
652
- },
653
- timing.button,
654
- );
655
- }
656
-
657
- if (imageFirstElements.length > 0) {
658
- heroTimeline.to(
659
- imageFirstElements,
660
- {
661
- opacity: 1,
662
- duration: config.appear.duration,
663
- ease: config.appear.ease,
664
- },
665
- 0,
666
- );
667
- }
668
-
669
- if (imageRegularElements.length > 0) {
670
- heroTimeline.to(
671
- imageRegularElements,
672
- {
673
- opacity: 1,
674
- duration: config.appear.duration,
675
- ease: config.appear.ease,
676
- },
677
- timing.image,
678
- );
679
- }
680
-
681
- // Combine appear elements and heading appear elements
682
- const allAppearElements = [...appearElements, ...headingAppearElements];
683
-
684
- if (allAppearElements.length > 0) {
685
- heroTimeline.to(
686
- allAppearElements,
687
- {
688
- y: 0,
689
- opacity: 1,
690
- duration: config.appear.duration,
691
- ease: config.appear.ease,
692
- onComplete: () => {
693
- // Check if interactions haven't been restored yet
694
- const stillDisabled = document.querySelector(
695
- "[data-original-tabindex]",
696
- );
697
- if (stillDisabled) {
698
- const allFocusableElements = document.querySelectorAll(
699
- "[data-original-tabindex]",
700
- );
701
- allFocusableElements.forEach((el) => {
702
- el.style.pointerEvents = "";
703
- const originalTabindex = el.getAttribute(
704
- "data-original-tabindex",
705
- );
706
- if (originalTabindex === "0") {
707
- el.removeAttribute("tabindex");
708
- } else {
709
- el.setAttribute("tabindex", originalTabindex);
710
- }
711
- el.removeAttribute("data-original-tabindex");
712
- });
713
- // Restore nav pointer events
714
- if (navElement) {
715
- navElement.style.pointerEvents = "";
716
- }
717
- }
718
- },
719
- },
720
- timing.appear,
721
- );
722
- } else {
723
- // If no appear elements, check if interactions need restoring when timeline completes
724
- heroTimeline.call(() => {
725
- const stillDisabled = document.querySelector(
726
- "[data-original-tabindex]",
727
- );
728
- if (stillDisabled) {
729
- const allFocusableElements = document.querySelectorAll(
730
- "[data-original-tabindex]",
731
- );
732
- allFocusableElements.forEach((el) => {
733
- el.style.pointerEvents = "";
734
- const originalTabindex = el.getAttribute(
735
- "data-original-tabindex",
736
- );
737
- if (originalTabindex === "0") {
738
- el.removeAttribute("tabindex");
739
- } else {
740
- el.setAttribute("tabindex", originalTabindex);
741
- }
742
- el.removeAttribute("data-original-tabindex");
743
- });
744
- // Restore nav pointer events
745
- if (navElement) {
746
- navElement.style.pointerEvents = "";
747
- }
748
- }
749
- });
750
- }
751
-
752
- // Handle main elements with CSS transitions (no GSAP)
753
- if (mainElements.length > 0) {
754
- heroTimeline.call(() => {
755
- mainElements.forEach((el) => {
756
- el.style.transition = "opacity 1s ease";
757
- el.style.opacity = "1";
758
- });
759
- }, null, timing.appear + 0.1);
760
- }
761
-
762
- heroTimeout = null;
763
- }, config.global.animationDelay * 1000);
764
- });
765
-
766
- // API exposure
767
- window[API_NAME] = window[API_NAME] || {};
768
- window[API_NAME].heroAnimations = {
769
- config: config,
770
- updateConfig: updateConfig,
771
- start: startHeroAnimations,
772
- kill: killHeroAnimations,
773
- restart: () => {
774
- killHeroAnimations();
775
- startHeroAnimations();
776
- },
777
- };
778
-
779
- // Add resize listener for responsive line splits
780
- let heroResizeTimeout;
781
- let lastWidth = window.innerWidth;
782
- window.addEventListener("resize", () => {
783
- const currentWidth = window.innerWidth;
784
- if (currentWidth !== lastWidth) {
785
- lastWidth = currentWidth;
786
- clearTimeout(heroResizeTimeout);
787
- heroResizeTimeout = setTimeout(() => {
788
- ScrollTrigger.refresh();
789
- }, 300);
790
- }
791
- });
792
-
793
- return { result: "anim-hero initialized" };
794
- }