@hortonstudio/main 1.2.26 → 1.2.27

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.
@@ -35,7 +35,8 @@
35
35
  "Bash(git remote remove:*)",
36
36
  "Bash(tree:*)",
37
37
  "Bash(grep:*)",
38
- "Bash(git reset:*)"
38
+ "Bash(git reset:*)",
39
+ "Bash(git checkout:*)"
39
40
  ],
40
41
  "deny": []
41
42
  }
@@ -468,7 +468,9 @@ export async function init() {
468
468
  ease: config.headingSplit.ease,
469
469
  onComplete: () => {
470
470
  if (split && split.revert) {
471
-
471
+ setTimeout(() => {
472
+ split.revert();
473
+ }, 100);
472
474
  }
473
475
  }
474
476
  },
@@ -487,7 +489,9 @@ export async function init() {
487
489
  ease: config.subheadingSplit.ease,
488
490
  onComplete: () => {
489
491
  if (split && split.revert) {
490
-
492
+ setTimeout(() => {
493
+ split.revert();
494
+ }, 100);
491
495
  }
492
496
  }
493
497
  },
@@ -597,72 +601,16 @@ export async function init() {
597
601
 
598
602
  // Add resize listener for responsive line splits
599
603
  let heroResizeTimeout;
604
+ let lastWidth = window.innerWidth;
600
605
  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);
606
+ const currentWidth = window.innerWidth;
607
+ if (currentWidth !== lastWidth) {
608
+ lastWidth = currentWidth;
609
+ clearTimeout(heroResizeTimeout);
610
+ heroResizeTimeout = setTimeout(() => {
611
+ ScrollTrigger.refresh();
612
+ }, 300);
613
+ }
666
614
  });
667
615
 
668
616
  return { result: 'anim-hero initialized' };
@@ -141,10 +141,13 @@ const CharSplitAnimations = {
141
141
  scrollTrigger: {
142
142
  trigger: textElement,
143
143
  start: config.charSplit.start,
144
- invalidateOnRefresh: true,
144
+ invalidateOnRefresh: false,
145
145
  },
146
146
  onComplete: () => {
147
-
147
+ if (textElement.splitTextInstance) {
148
+ textElement.splitTextInstance.revert();
149
+ delete textElement.splitTextInstance;
150
+ }
148
151
  }
149
152
  });
150
153
 
@@ -198,10 +201,13 @@ const WordSplitAnimations = {
198
201
  scrollTrigger: {
199
202
  trigger: textElement,
200
203
  start: config.wordSplit.start,
201
- invalidateOnRefresh: true,
204
+ invalidateOnRefresh: false,
202
205
  },
203
206
  onComplete: () => {
204
-
207
+ if (textElement.splitTextInstance) {
208
+ textElement.splitTextInstance.revert();
209
+ delete textElement.splitTextInstance;
210
+ }
205
211
  }
206
212
  });
207
213
 
@@ -255,10 +261,13 @@ const LineSplitAnimations = {
255
261
  scrollTrigger: {
256
262
  trigger: textElement,
257
263
  start: config.lineSplit.start,
258
- invalidateOnRefresh: true,
264
+ invalidateOnRefresh: false,
259
265
  },
260
266
  onComplete: () => {
261
-
267
+ if (textElement.splitTextInstance) {
268
+ textElement.splitTextInstance.revert();
269
+ delete textElement.splitTextInstance;
270
+ }
262
271
  }
263
272
  });
264
273
 
@@ -303,7 +312,7 @@ const AppearAnimations = {
303
312
  scrollTrigger: {
304
313
  trigger: element,
305
314
  start: config.appear.start,
306
- invalidateOnRefresh: true,
315
+ invalidateOnRefresh: false,
307
316
  }
308
317
  });
309
318
 
@@ -352,25 +361,16 @@ export async function init() {
352
361
  }
353
362
 
354
363
  let resizeTimeout;
364
+ let lastWidth = window.innerWidth;
355
365
  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);
366
+ const currentWidth = window.innerWidth;
367
+ if (currentWidth !== lastWidth) {
368
+ lastWidth = currentWidth;
369
+ clearTimeout(resizeTimeout);
370
+ resizeTimeout = setTimeout(() => {
371
+ ScrollTrigger.refresh();
372
+ }, 300);
373
+ }
374
374
  });
375
375
 
376
376
  const api = window[API_NAME] || {};
@@ -21,18 +21,28 @@ function initTransitions() {
21
21
 
22
22
  // On Page Load
23
23
  if (transitionTrigger.length > 0) {
24
- if (window.Webflow && window.Webflow.push) {
25
- Webflow.push(function () {
26
- transitionTrigger.click();
27
- });
24
+
25
+ function triggerTransition() {
26
+ if (window.Webflow && window.Webflow.push) {
27
+ Webflow.push(function () {
28
+ transitionTrigger.click();
29
+ });
30
+ } else {
31
+ // Non-Webflow initialization
32
+ setTimeout(() => {
33
+ transitionTrigger.click();
34
+ }, 100);
35
+ }
36
+ $("body").addClass("no-scroll-transition");
37
+ setTimeout(() => {$("body").removeClass("no-scroll-transition");}, introDurationMS);
38
+ }
39
+
40
+ // Wait for full page load (images, fonts, etc.) for Safari
41
+ if (document.readyState === 'complete') {
42
+ triggerTransition();
28
43
  } else {
29
- // Non-Webflow initialization
30
- setTimeout(() => {
31
- transitionTrigger.click();
32
- }, 100);
44
+ window.addEventListener('load', triggerTransition, { once: true });
33
45
  }
34
- $("body").addClass("no-scroll-transition");
35
- setTimeout(() => {$("body").removeClass("no-scroll-transition");}, introDurationMS);
36
46
  }
37
47
 
38
48
  // On Link Click
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version:1.2.26
1
+ // Version:1.2.27
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.26",
3
+ "version": "1.2.27",
4
4
  "description": "Animation and utility library for client websites",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,32 +0,0 @@
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();