@hortonstudio/main 1.2.25 → 1.2.26

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.
@@ -595,5 +595,75 @@ export async function init() {
595
595
  }
596
596
  };
597
597
 
598
+ // Add resize listener for responsive line splits
599
+ let heroResizeTimeout;
600
+ window.addEventListener('resize', () => {
601
+ clearTimeout(heroResizeTimeout);
602
+ heroResizeTimeout = setTimeout(() => {
603
+ // Only refresh line splits, not chars or words
604
+ const hasLineSplits = headingSplits.some(split => split.elementsClass === 'lines') ||
605
+ subheadingSplits.some(split => split.elementsClass === 'lines');
606
+
607
+ if (hasLineSplits) {
608
+ // Kill current line splits
609
+ headingSplits.forEach((split, index) => {
610
+ if (split.elementsClass === 'lines' && split.revert) {
611
+ split.revert();
612
+ }
613
+ });
614
+
615
+ subheadingSplits.forEach((split, index) => {
616
+ if (split.elementsClass === 'lines' && split.revert) {
617
+ split.revert();
618
+ }
619
+ });
620
+
621
+ // Re-initialize line splits after resize
622
+ document.fonts.ready.then(() => {
623
+ // Re-split line elements
624
+ headingSplitElements.forEach((parent, index) => {
625
+ const textElement = heading[index];
626
+ const splitType = parent.getAttribute('data-hs-heroconfig') || 'line';
627
+
628
+ if (splitType === 'line') {
629
+ const splitConfig = {
630
+ type: "lines",
631
+ mask: "lines",
632
+ linesClass: "line"
633
+ };
634
+
635
+ const split = new SplitText(textElement, splitConfig);
636
+ split.elementsClass = 'lines';
637
+ headingSplits[index] = split;
638
+
639
+ gsap.set(split.lines, { yPercent: 0 });
640
+ }
641
+ });
642
+
643
+ subheadingSplitElements.forEach((parent, index) => {
644
+ const textElement = subheading[index];
645
+ const splitType = parent.getAttribute('data-hs-heroconfig') || 'word';
646
+
647
+ if (splitType === 'line') {
648
+ const splitConfig = {
649
+ type: "lines",
650
+ mask: "lines",
651
+ linesClass: "line"
652
+ };
653
+
654
+ const split = new SplitText(textElement, splitConfig);
655
+ split.elementsClass = 'lines';
656
+ subheadingSplits[index] = split;
657
+
658
+ gsap.set(split.lines, { yPercent: 0 });
659
+ }
660
+ });
661
+ });
662
+ }
663
+
664
+ ScrollTrigger.refresh();
665
+ }, 100);
666
+ });
667
+
598
668
  return { result: 'anim-hero initialized' };
599
669
  }
@@ -115,7 +115,7 @@ const CharSplitAnimations = {
115
115
 
116
116
  elements.forEach((textElement) => {
117
117
  const split = SplitText.create(textElement, {
118
- type: "chars",
118
+ type: "words,chars",
119
119
  mask: "chars",
120
120
  charsClass: "char",
121
121
  });
@@ -351,7 +351,27 @@ export async function init() {
351
351
  initAnimations();
352
352
  }
353
353
 
354
- window.addEventListener('resize', ScrollTrigger.refresh());
354
+ let resizeTimeout;
355
+ window.addEventListener('resize', () => {
356
+ clearTimeout(resizeTimeout);
357
+ resizeTimeout = setTimeout(() => {
358
+ // Kill and restart line split animations on resize
359
+ const lineSplitElements = document.querySelectorAll(".a-line-split > *:first-child");
360
+ lineSplitElements.forEach((textElement) => {
361
+ if (textElement.splitTextInstance) {
362
+ textElement.splitTextInstance.revert();
363
+ delete textElement.splitTextInstance;
364
+ }
365
+ });
366
+
367
+ // Re-initialize line splits after resize
368
+ LineSplitAnimations.initial().then(() => {
369
+ LineSplitAnimations.animate();
370
+ });
371
+
372
+ ScrollTrigger.refresh();
373
+ }, 100);
374
+ });
355
375
 
356
376
  const api = window[API_NAME] || {};
357
377
  api.textAnimations = {
@@ -0,0 +1,32 @@
1
+ function configure() {
2
+ // Check if hsmain is loaded AND the specific animation modules are available
3
+ if (!window.hsmain?.loaded ||
4
+ !window.hsmain?.textAnimations?.updateConfig ||
5
+ !window.hsmain?.heroAnimations?.updateConfig) {
6
+ setTimeout(configure, 10);
7
+ return;
8
+ }
9
+
10
+ const api = window.hsmain;
11
+
12
+ try {
13
+ api.textAnimations.updateConfig({
14
+ // your text animation config
15
+ });
16
+
17
+ api.heroAnimations.updateConfig({
18
+ headingSplit: {
19
+ // your hero animation config
20
+ }
21
+ });
22
+
23
+ api.textAnimations.restart();
24
+ api.heroAnimations.restart();
25
+ } catch (error) {
26
+ console.warn('Animation configuration failed:', error);
27
+ // Retry after a short delay if needed
28
+ setTimeout(configure, 50);
29
+ }
30
+ }
31
+
32
+ configure();
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version:1.2.25
1
+ // Version:1.2.26
2
2
 
3
3
  const API_NAME = 'hsmain';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hortonstudio/main",
3
- "version": "1.2.25",
3
+ "version": "1.2.26",
4
4
  "description": "Animation and utility library for client websites",
5
5
  "main": "index.js",
6
6
  "type": "module",