@hortonstudio/main 1.1.5 → 1.1.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.
Files changed (2) hide show
  1. package/index.js +18 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -12,7 +12,8 @@ const animationModules = {
12
12
 
13
13
  const utilityModules = {
14
14
  "data-hs-util-toc": "./utils/toc.js",
15
- "data-hs-util-progress": "./utils/scroll-progress.js"
15
+ "data-hs-util-progress": "./utils/scroll-progress.js",
16
+ "data-hs-util-navbar": "./utils/navbar.js"
16
17
  };
17
18
 
18
19
  // Modules that auto-initialize
@@ -26,12 +27,12 @@ const postWebflowCallbacks = [];
26
27
  const loadModule = (moduleName) => {
27
28
  // Check manual modules first
28
29
  let modulePath = animationModules[moduleName] || utilityModules[moduleName];
29
-
30
+
30
31
  // Then check auto-init modules
31
32
  if (!modulePath) {
32
33
  modulePath = autoInitModules[moduleName];
33
34
  }
34
-
35
+
35
36
  if (!modulePath) {
36
37
  throw new Error(`HortonStudio module "${moduleName}" is not supported.`);
37
38
  }
@@ -45,32 +46,40 @@ const findCurrentScriptTag = () => {
45
46
 
46
47
  const processModules = async (scriptTag) => {
47
48
  const modulePromises = [];
48
-
49
+
49
50
  // Load manual modules based on attributes
50
51
  for (const moduleName of Object.keys({ ...animationModules, ...utilityModules })) {
51
52
  if (scriptTag && scriptTag.hasAttribute(moduleName)) {
52
53
  modulePromises.push(loadHsModule(moduleName));
53
54
  }
54
55
  }
55
-
56
+
56
57
  // Load auto-init modules
57
58
  for (const moduleName of Object.keys(autoInitModules)) {
58
59
  modulePromises.push(loadHsModule(moduleName));
59
60
  }
60
-
61
+
62
+ // Hide .transition elements if transition module is not loaded
63
+ if (!scriptTag || !scriptTag.hasAttribute('data-hs-anim-transition')) {
64
+ const transitionElements = document.querySelectorAll('.transition');
65
+ transitionElements.forEach(element => {
66
+ element.style.display = 'none';
67
+ });
68
+ }
69
+
61
70
  // Wait for ALL modules to finish loading
62
71
  await Promise.all(modulePromises);
63
-
72
+
64
73
  // Always refresh Webflow after all modules are loaded
65
74
  refreshWebflow();
66
75
  };
67
76
 
68
77
  const refreshWebflow = () => {
69
-
78
+
70
79
  setTimeout(() => {
71
80
  if (window.Webflow && window.Webflow.ready) {
72
81
  window.Webflow.ready();
73
-
82
+
74
83
  // Run all registered post-Webflow callbacks
75
84
  setTimeout(() => {
76
85
  postWebflowCallbacks.forEach(callback => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hortonstudio/main",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {