@hortonstudio/main 1.2.29 → 1.2.30

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.
package/autoInit/modal.js CHANGED
@@ -1,10 +1,35 @@
1
1
  function initModal() {
2
2
  const config = {
3
3
  transitionDuration: 0.3,
4
- blurOpacity: 0.5
4
+ blurOpacity: 0.5,
5
+ breakpoints: {
6
+ mobile: 479,
7
+ tablet: 767,
8
+ desktop: 991
9
+ }
5
10
  };
6
11
 
12
+ function getCurrentBreakpoint() {
13
+ const width = window.innerWidth;
14
+ if (width <= config.breakpoints.mobile) return 'mobile';
15
+ if (width <= config.breakpoints.tablet) return 'tablet';
16
+ if (width <= config.breakpoints.desktop) return 'desktop';
17
+ return 'desktop-large';
18
+ }
19
+
20
+ function shouldPreventModal(element) {
21
+ const preventAttr = element.getAttribute('data-hs-modalprevent');
22
+ if (!preventAttr) return false;
23
+
24
+ const currentBreakpoint = getCurrentBreakpoint();
25
+ const preventBreakpoints = preventAttr.split(',').map(bp => bp.trim());
26
+
27
+ return preventBreakpoints.includes(currentBreakpoint);
28
+ }
29
+
7
30
  function openModal(element) {
31
+ if (shouldPreventModal(element)) return;
32
+
8
33
  document.body.classList.add('u-overflow-clip');
9
34
 
10
35
  // Add blur to all other modals
@@ -30,6 +55,15 @@ function initModal() {
30
55
  });
31
56
  }
32
57
 
58
+ function forceClosePreventedModals() {
59
+ document.querySelectorAll('[data-hs-modalprevent]').forEach(element => {
60
+ if (shouldPreventModal(element) && element.x) {
61
+ element.x = 0;
62
+ closeModal(element);
63
+ }
64
+ });
65
+ }
66
+
33
67
  function toggleModal(element) {
34
68
  element.x = ((element.x || 0) + 1) % 2;
35
69
 
@@ -61,6 +95,11 @@ function initModal() {
61
95
  });
62
96
  });
63
97
 
98
+ // Handle window resize to check for prevented modals
99
+ window.addEventListener('resize', function() {
100
+ forceClosePreventedModals();
101
+ });
102
+
64
103
  return { result: 'modal initialized' };
65
104
  }
66
105
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version:1.2.29
1
+ // Version:1.2.30
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.29",
3
+ "version": "1.2.30",
4
4
  "description": "Animation and utility library for client websites",
5
5
  "main": "index.js",
6
6
  "type": "module",