@hortonstudio/main 1.9.7 → 1.9.9

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## **Overview**
4
4
 
5
- The accessibility system provides 11 modular functions to enhance website accessibility and functionality. Each function operates independently and can be customized through data attributes.
5
+ The accessibility system provides 7 modular functions to enhance website accessibility and functionality. Each function operates independently and can be customized through data attributes.
6
6
 
7
7
  **Note:** This module auto-initializes and loads all functions on page load.
8
8
 
@@ -24,63 +24,35 @@ Adds proper ARIA `role="list"` and `role="listitem"` to custom-styled lists.
24
24
 
25
25
  ---
26
26
 
27
- ### **3. Remove List Accessibility**
28
- Removes list semantics by stripping ARIA roles and converting `<ul>/<ol>/<li>` to divs.
29
-
30
- **Use case:** Decorative list layouts that shouldn't be announced as lists.
31
-
32
- ---
33
-
34
- ### **4. Convert to Span**
35
- Converts most HTML elements to span elements while preserving attributes and content.
36
-
37
- **Use case:** Removing semantic meaning from purely decorative wrapper elements.
38
-
39
- ---
40
-
41
- ### **5. Year Replacement**
27
+ ### **3. Year Replacement**
42
28
  Replaces `{{year}}` and `{{month}}` placeholders with current year and month.
43
29
 
44
30
  **Use case:** Auto-updating copyright years and date-based content.
45
31
 
46
32
  ---
47
33
 
48
- ### **6. Prevent Default**
49
- Prevents default behavior on elements including clicks and keyboard activation.
50
-
51
- **Use case:** Decorative buttons or preventing anchor link scrolling.
52
-
53
- ---
54
-
55
- ### **7. Custom Values Replacement**
56
- Collects custom name-value pairs and replaces `{{name}}` placeholders throughout the page.
57
-
58
- **Use case:** Dynamic content replacement for user-defined values.
59
-
60
- ---
61
-
62
- ### **8. Click Forwarding**
34
+ ### **4. Click Forwarding**
63
35
  Forwards clicks from decorative wrapper elements to actual interactive trigger elements.
64
36
 
65
37
  **Use case:** Making entire card areas clickable while maintaining semantic structure.
66
38
 
67
39
  ---
68
40
 
69
- ### **9. Text Synchronization**
41
+ ### **5. Text Synchronization**
70
42
  Synchronizes text content and aria-labels from original element to multiple match elements in real-time.
71
43
 
72
44
  **Use case:** Keeping duplicate content in sync across multiple locations.
73
45
 
74
46
  ---
75
47
 
76
- ### **10. Table of Contents (TOC)**
48
+ ### **6. Table of Contents (TOC)**
77
49
  Automatically generates a table of contents from H2 headings with smooth scrolling, focus management, and active state tracking.
78
50
 
79
51
  **Use case:** Auto-generated TOC navigation for blog posts and documentation pages.
80
52
 
81
53
  ---
82
54
 
83
- ### **11. Dropdown**
55
+ ### **7. Dropdown**
84
56
  Universal dropdown system for FAQ, summary/read-more, and general toggle components. Syncs ARIA with Webflow interactions and optionally updates text content.
85
57
 
86
58
  **Use case:** All dropdown/accordion/toggle patterns with unified ARIA management and optional text swapping.
@@ -95,11 +67,7 @@ Each function has detailed documentation in its respective folder:
95
67
 
96
68
  - `functions/blog-remover/README.md`
97
69
  - `functions/list-accessibility/README.md`
98
- - `functions/remove-list-accessibility/README.md`
99
- - `functions/convert-to-span/README.md`
100
70
  - `functions/year-replacement/README.md`
101
- - `functions/prevent-default/README.md`
102
- - `functions/custom-values-replacement/README.md`
103
71
  - `functions/click-forwarding/README.md`
104
72
  - `functions/text-synchronization/README.md`
105
73
  - `functions/toc/README.md`
@@ -8,11 +8,7 @@ export async function init() {
8
8
  const functionMap = {
9
9
  "blog-remover": () => import("./functions/blog-remover/blog-remover.js"),
10
10
  "list-accessibility": () => import("./functions/list-accessibility/list-accessibility.js"),
11
- "remove-list-accessibility": () => import("./functions/remove-list-accessibility/remove-list-accessibility.js"),
12
- "convert-to-span": () => import("./functions/convert-to-span/convert-to-span.js"),
13
11
  "year-replacement": () => import("./functions/year-replacement/year-replacement.js"),
14
- "prevent-default": () => import("./functions/prevent-default/prevent-default.js"),
15
- "custom-values-replacement": () => import("./functions/custom-values-replacement/custom-values-replacement.js"),
16
12
  "click-forwarding": () => import("./functions/click-forwarding/click-forwarding.js"),
17
13
  "text-synchronization": () => import("./functions/text-synchronization/text-synchronization.js"),
18
14
  "toc": () => import("./functions/toc/toc.js"),
package/index.js CHANGED
@@ -25,8 +25,8 @@ const initializeHsMain = async () => {
25
25
 
26
26
  const moduleMap = {
27
27
  transition: () => import("./autoInit/transition/transition.js"),
28
- "data-hs-util-ba": () => import("./utils/before-after.js"),
29
- "data-hs-util-slider": () => import("./utils/slider.js"),
28
+ "data-hs-util-ba": () => import("./utils/before-after/before-after.js"),
29
+ "data-hs-util-slider": () => import("./utils/slider/slider.js"),
30
30
  "smooth-scroll": () => import("./autoInit/smooth-scroll/smooth-scroll.js"),
31
31
  navbar: () => import("./autoInit/navbar/navbar.js"),
32
32
  accessibility: () => import("./autoInit/accessibility/accessibility.js"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hortonstudio/main",
3
- "version": "1.9.7",
3
+ "version": "1.9.9",
4
4
  "description": "Animation and utility library for client websites",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,243 @@
1
+ # **Before/After Image Comparison**
2
+
3
+ ## **Overview**
4
+
5
+ Interactive before/after image comparison utility with multiple viewing modes, slider controls, and carousel functionality. Supports keyboard navigation, touch gestures, and accessibility features.
6
+
7
+ **Note:** This utility is loaded via `data-hs-util-ba` attribute on the script tag in index.js.
8
+
9
+ ---
10
+
11
+ ## **Features**
12
+
13
+ - **Three Viewing Modes**: Before, After, and Split (slider)
14
+ - **Multiple Items**: Carousel navigation with arrows and pagination
15
+ - **Slider Control**: Draggable slider with click-to-position
16
+ - **Keyboard Support**: Arrow keys for navigation and slider control
17
+ - **Touch Gestures**: Full mobile touch support
18
+ - **Accessibility**: ARIA attributes and keyboard navigation
19
+
20
+ ---
21
+
22
+ ## **Required Elements**
23
+
24
+ **Wrapper**
25
+ * data-hs-ba="wrapper"
26
+ * Container for entire before/after instance
27
+
28
+ **Image Wrapper**
29
+ * data-hs-ba="image-wrapper"
30
+ * Container for before/after images
31
+ * Focusable for keyboard slider control
32
+
33
+ **Before Image**
34
+ * data-hs-ba="image-before"
35
+ * Background/base image layer
36
+
37
+ **After Image**
38
+ * data-hs-ba="image-after"
39
+ * Foreground image with clip-path
40
+
41
+ **Slider** *(optional)*
42
+ * data-hs-ba="slider"
43
+ * Draggable handle for split view
44
+
45
+ **Mode Buttons** *(optional)*
46
+ * data-hs-ba="mode-before"
47
+ * data-hs-ba="mode-after"
48
+ * data-hs-ba="mode-split"
49
+
50
+ **Navigation** *(optional, for multiple items)*
51
+ * data-hs-ba="left" - Previous item
52
+ * data-hs-ba="right" - Next item
53
+
54
+ **Pagination** *(optional)*
55
+ * data-hs-ba="pagination"
56
+ * Container with template dot (first child)
57
+
58
+ ---
59
+
60
+ ## **Usage Example**
61
+
62
+ ### **Single Comparison**
63
+
64
+ ```html
65
+ <div data-hs-ba="wrapper">
66
+ <div data-hs-ba="image-wrapper">
67
+ <img data-hs-ba="image-before" src="before.jpg" alt="Before">
68
+ <img data-hs-ba="image-after" src="after.jpg" alt="After">
69
+ <div data-hs-ba="slider">
70
+ <!-- Slider handle content -->
71
+ </div>
72
+ </div>
73
+
74
+ <!-- Mode buttons -->
75
+ <button data-hs-ba="mode-before">Before</button>
76
+ <button data-hs-ba="mode-split">Split</button>
77
+ <button data-hs-ba="mode-after">After</button>
78
+ </div>
79
+ ```
80
+
81
+ ---
82
+
83
+ ### **Multiple Items with Carousel**
84
+
85
+ ```html
86
+ <div data-hs-ba="wrapper">
87
+ <!-- Item 1 -->
88
+ <div>
89
+ <div data-hs-ba="image-wrapper">
90
+ <img data-hs-ba="image-before" src="before-1.jpg">
91
+ <img data-hs-ba="image-after" src="after-1.jpg">
92
+ <div data-hs-ba="slider"></div>
93
+ </div>
94
+ <button data-hs-ba="mode-before">Before</button>
95
+ <button data-hs-ba="mode-split">Split</button>
96
+ <button data-hs-ba="mode-after">After</button>
97
+ </div>
98
+
99
+ <!-- Item 2 -->
100
+ <div>
101
+ <div data-hs-ba="image-wrapper">
102
+ <img data-hs-ba="image-before" src="before-2.jpg">
103
+ <img data-hs-ba="image-after" src="after-2.jpg">
104
+ <div data-hs-ba="slider"></div>
105
+ </div>
106
+ <button data-hs-ba="mode-before">Before</button>
107
+ <button data-hs-ba="mode-split">Split</button>
108
+ <button data-hs-ba="mode-after">After</button>
109
+ </div>
110
+
111
+ <!-- Navigation -->
112
+ <button data-hs-ba="left">Previous</button>
113
+ <button data-hs-ba="right">Next</button>
114
+
115
+ <!-- Pagination -->
116
+ <div data-hs-ba="pagination">
117
+ <div class="dot"></div> <!-- Template -->
118
+ </div>
119
+ </div>
120
+ ```
121
+
122
+ ---
123
+
124
+ ## **Viewing Modes**
125
+
126
+ ### **Before Mode**
127
+ - Shows only the before image
128
+ - Hides slider
129
+ - Clips after image to 100% (invisible)
130
+
131
+ ### **After Mode**
132
+ - Shows only the after image
133
+ - Hides slider
134
+ - Clips after image to 0% (fully visible)
135
+
136
+ ### **Split Mode** *(default)*
137
+ - Shows both images side by side
138
+ - Slider visible and draggable
139
+ - Default split at 50%
140
+ - Clicking split mode button resets to 50%
141
+
142
+ ---
143
+
144
+ ## **Keyboard Navigation**
145
+
146
+ ### **Main Wrapper Focus:**
147
+ - `Arrow Left/Right/Up/Down`: Navigate between items
148
+
149
+ ### **Image Wrapper Focus:**
150
+ - `Arrow Left`: Move slider left (in split mode)
151
+ - `Arrow Right`: Move slider right (in split mode)
152
+ - Step size: 5% per press (configurable)
153
+
154
+ ---
155
+
156
+ ## **Configuration**
157
+
158
+ Default configuration can be updated via `window.hsmain.utilBeforeAfter.updateConfig()`:
159
+
160
+ ```javascript
161
+ {
162
+ defaultMode: "split", // Initial viewing mode
163
+ sliderPosition: 50, // Default slider position (%)
164
+ touchSensitivity: 1, // Touch drag sensitivity
165
+ keyboardStep: 5, // Keyboard arrow step (%)
166
+ autoPlay: false, // Auto-advance items
167
+ autoPlayInterval: 5000 // Auto-play interval (ms)
168
+ }
169
+ ```
170
+
171
+ ---
172
+
173
+ ## **API Methods**
174
+
175
+ Accessible via `window.hsmain.utilBeforeAfter`:
176
+
177
+ ### **showSlide(instanceId, index)**
178
+ Navigate to specific item in carousel
179
+
180
+ ```javascript
181
+ window.hsmain.utilBeforeAfter.showSlide(0, 2); // Go to third item
182
+ ```
183
+
184
+ ### **setMode(instanceId, mode)**
185
+ Change viewing mode programmatically
186
+
187
+ ```javascript
188
+ window.hsmain.utilBeforeAfter.setMode(0, 'before');
189
+ ```
190
+
191
+ ### **updateConfig(newConfig)**
192
+ Update global configuration
193
+
194
+ ```javascript
195
+ window.hsmain.utilBeforeAfter.updateConfig({
196
+ sliderPosition: 60,
197
+ keyboardStep: 10
198
+ });
199
+ ```
200
+
201
+ ---
202
+
203
+ ## **Accessibility Features**
204
+
205
+ - Wrapper has `role="application"` with descriptive aria-label
206
+ - Image wrapper has `role="img"` and keyboard instructions
207
+ - Pagination dots have proper ARIA attributes
208
+ - All interactive elements are keyboard accessible
209
+ - Focus management between items
210
+ - Slider position persists across item navigation
211
+
212
+ ---
213
+
214
+ ## **Touch Support**
215
+
216
+ - Drag slider handle on touch devices
217
+ - Click/tap image wrapper to position slider
218
+ - Touch-friendly navigation buttons
219
+ - Prevents default scroll during drag
220
+
221
+ ---
222
+
223
+ ## **How It Works**
224
+
225
+ 1. **Initialization**: Finds all `[data-hs-ba="wrapper"]` elements
226
+ 2. **Instance Creation**: Each wrapper becomes independent instance
227
+ 3. **Carousel Setup**: Multiple items get navigation and pagination
228
+ 4. **Mode Management**: Buttons control image visibility via clip-path
229
+ 5. **Slider Dragging**: Mouse/touch events update clip-path in real-time
230
+ 6. **Keyboard Control**: Arrow keys navigate items and adjust slider
231
+ 7. **State Persistence**: Slider position maintained across item changes
232
+
233
+ ---
234
+
235
+ ## **Notes**
236
+
237
+ - Each wrapper is an independent instance
238
+ - Slider position persists when navigating items
239
+ - Pagination automatically generated from items
240
+ - First pagination dot used as template
241
+ - Supports any number of items (1+)
242
+ - Cleanup on destroy for Barba.js compatibility
243
+ - Caches DOM queries for performance