@hortonstudio/main 1.7.10 → 1.7.12

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.
@@ -64,7 +64,7 @@ export function init() {
64
64
  observer = new IntersectionObserver((entries) => {
65
65
  entries.forEach((entry) => {
66
66
  if (entry.isIntersecting && !entry.target.dataset.animated) {
67
- const numberElement = entry.target.querySelector('[data-hs-counter="number"]');
67
+ const numberElement = entry.target.querySelector('[data-hs-anim="counter"]');
68
68
  startAnimation(numberElement);
69
69
  entry.target.dataset.animated = "true";
70
70
  }
@@ -84,7 +84,7 @@ export function init() {
84
84
  const statsElements = document.querySelectorAll('[data-hs-counter="wrapper"]');
85
85
 
86
86
  statsElements.forEach((element) => {
87
- const numberElement = element.querySelector('[data-hs-counter="number"]');
87
+ const numberElement = element.querySelector('[data-hs-anim="counter"]');
88
88
  const originalText = numberElement.getAttribute("data-hs-original");
89
89
 
90
90
  element.setAttribute("aria-label", originalText);
@@ -101,7 +101,7 @@ export function init() {
101
101
  const wrappers = document.querySelectorAll('[data-hs-counter="wrapper"]');
102
102
 
103
103
  wrappers.forEach((wrapper) => {
104
- const numberElement = wrapper.querySelector('[data-hs-counter="number"]');
104
+ const numberElement = wrapper.querySelector('[data-hs-anim="counter"]');
105
105
  const parsed = parseText(numberElement.textContent.trim());
106
106
 
107
107
  numberElement.setAttribute("data-hs-original", numberElement.textContent.trim());
@@ -119,7 +119,7 @@ export function init() {
119
119
 
120
120
  function triggerAnimation(selector) {
121
121
  const wrapper = document.querySelector(selector);
122
- const numberElement = wrapper.querySelector('[data-hs-counter="number"]');
122
+ const numberElement = wrapper.querySelector('[data-hs-anim="counter"]');
123
123
  startAnimation(numberElement);
124
124
  wrapper.dataset.animated = "true";
125
125
  }
@@ -127,7 +127,7 @@ export function init() {
127
127
  function reset() {
128
128
  counters.forEach((wrapper) => {
129
129
  delete wrapper.dataset.animated;
130
- const numberElement = wrapper.querySelector('[data-hs-counter="number"]');
130
+ const numberElement = wrapper.querySelector('[data-hs-anim="counter"]');
131
131
  numberElement.textContent = numberElement.getAttribute("data-hs-original");
132
132
  });
133
133
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version:1.7.10
1
+ // Version:1.7.12
2
2
  const API_NAME = "hsmain";
3
3
 
4
4
  const initializeHsMain = async () => {
@@ -254,6 +254,28 @@ const initializeHsMain = async () => {
254
254
  });
255
255
  });
256
256
 
257
+ const waitForIx2 = async () => {
258
+ const startTime = Date.now();
259
+ const timeout = 2000; // 2 second timeout
260
+
261
+ return new Promise((resolve) => {
262
+ const checkIx2 = () => {
263
+ const htmlElement = document.documentElement;
264
+ const hasIx2 = htmlElement.classList.contains('w-mod-ix3');
265
+
266
+ if (hasIx2) {
267
+ resolve(true);
268
+ } else if (Date.now() - startTime >= timeout) {
269
+ console.warn('[hsmain] IX2 (w-mod-ix3) not detected after 2s timeout. Proceeding anyway, but Webflow interactions may not be fully loaded.');
270
+ resolve(false);
271
+ } else {
272
+ setTimeout(checkIx2, 50);
273
+ }
274
+ };
275
+ checkIx2();
276
+ });
277
+ };
278
+
257
279
  const finalize = async () => {
258
280
  processModules();
259
281
  await waitForWebflow();
@@ -266,6 +288,9 @@ const initializeHsMain = async () => {
266
288
  window.Webflow.ready();
267
289
  }
268
290
 
291
+ // Wait for IX2 to be ready before firing callbacks
292
+ await waitForIx2();
293
+
269
294
  window[API_NAME].loaded = true;
270
295
  readyCallbacks.forEach((callback) => {
271
296
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hortonstudio/main",
3
- "version": "1.7.10",
3
+ "version": "1.7.12",
4
4
  "description": "Animation and utility library for client websites",
5
5
  "main": "index.js",
6
6
  "type": "module",