@hortonstudio/main 1.2.30 → 1.2.31

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
@@ -3,9 +3,8 @@ function initModal() {
3
3
  transitionDuration: 0.3,
4
4
  blurOpacity: 0.5,
5
5
  breakpoints: {
6
- mobile: 479,
7
- tablet: 767,
8
- desktop: 991
6
+ mobile: 767,
7
+ tablet: 991
9
8
  }
10
9
  };
11
10
 
@@ -13,8 +12,7 @@ function initModal() {
13
12
  const width = window.innerWidth;
14
13
  if (width <= config.breakpoints.mobile) return 'mobile';
15
14
  if (width <= config.breakpoints.tablet) return 'tablet';
16
- if (width <= config.breakpoints.desktop) return 'desktop';
17
- return 'desktop-large';
15
+ return 'desktop';
18
16
  }
19
17
 
20
18
  function shouldPreventModal(element) {
@@ -55,11 +53,23 @@ function initModal() {
55
53
  });
56
54
  }
57
55
 
58
- function forceClosePreventedModals() {
56
+ // Store modal states that were closed due to prevention
57
+ let preventedModalStates = new Map();
58
+
59
+ function handleBreakpointChange() {
59
60
  document.querySelectorAll('[data-hs-modalprevent]').forEach(element => {
60
- if (shouldPreventModal(element) && element.x) {
61
+ const elementKey = element.getAttribute('data-hs-modal') + '_' + (element.id || element.className);
62
+ const shouldPrevent = shouldPreventModal(element);
63
+ const wasStoredAsOpen = preventedModalStates.get(elementKey);
64
+
65
+ if (shouldPrevent && element.x) {
66
+ preventedModalStates.set(elementKey, true);
61
67
  element.x = 0;
62
68
  closeModal(element);
69
+ } else if (!shouldPrevent && wasStoredAsOpen) {
70
+ preventedModalStates.delete(elementKey);
71
+ element.x = 1;
72
+ openModal(element);
63
73
  }
64
74
  });
65
75
  }
@@ -97,7 +107,7 @@ function initModal() {
97
107
 
98
108
  // Handle window resize to check for prevented modals
99
109
  window.addEventListener('resize', function() {
100
- forceClosePreventedModals();
110
+ handleBreakpointChange();
101
111
  });
102
112
 
103
113
  return { result: 'modal initialized' };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version:1.2.30
1
+ // Version:1.2.31
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.30",
3
+ "version": "1.2.31",
4
4
  "description": "Animation and utility library for client websites",
5
5
  "main": "index.js",
6
6
  "type": "module",