@hortonstudio/main 1.9.9 → 1.9.10
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/accessibility/README.md +9 -1
- package/autoInit/accessibility/accessibility.js +2 -1
- package/autoInit/accessibility/functions/pagination/README.md +428 -0
- package/{utils/slider/slider.js → autoInit/accessibility/functions/pagination/pagination.js} +173 -242
- package/index.js +0 -2
- package/package.json +1 -1
- package/utils/before-after/README.md +352 -75
- package/utils/slider/README.md +0 -299
package/utils/slider/README.md
DELETED
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
# **Slider/Carousel Utility**
|
|
2
|
-
|
|
3
|
-
## **Overview**
|
|
4
|
-
|
|
5
|
-
Flexible slider/carousel system supporting infinite carousels and paginated lists with responsive layouts, keyboard navigation, and accessibility features.
|
|
6
|
-
|
|
7
|
-
**Note:** This utility is loaded via `data-hs-util-slider` attribute on the script tag in index.js.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## **Features**
|
|
12
|
-
|
|
13
|
-
- **Infinite Carousel**: Seamless looping with GSAP animations
|
|
14
|
-
- **Pagination Slider**: Multi-item pages with infinite loop
|
|
15
|
-
- **Responsive**: Desktop/mobile breakpoints with different item counts
|
|
16
|
-
- **Keyboard Support**: Full keyboard navigation
|
|
17
|
-
- **Accessibility**: ARIA attributes, live regions, focus management
|
|
18
|
-
- **Dot Navigation**: Click dots to jump to any page
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## **Slider Types**
|
|
23
|
-
|
|
24
|
-
### **1. Infinite Carousel**
|
|
25
|
-
|
|
26
|
-
Basic infinite loop slider with next/prev buttons.
|
|
27
|
-
|
|
28
|
-
**Required Elements:**
|
|
29
|
-
- `data-hs-slider="wrapper"` - Container for slides
|
|
30
|
-
- `data-hs-slider="next"` - Next button
|
|
31
|
-
- `data-hs-slider="previous"` - Previous button
|
|
32
|
-
|
|
33
|
-
**Example:**
|
|
34
|
-
```html
|
|
35
|
-
<div data-hs-slider="wrapper">
|
|
36
|
-
<div>Slide 1</div>
|
|
37
|
-
<div>Slide 2</div>
|
|
38
|
-
<div>Slide 3</div>
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<button data-hs-slider="previous">Prev</button>
|
|
42
|
-
<button data-hs-slider="next">Next</button>
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
**How it works:**
|
|
46
|
-
- Clones first and last slides for seamless loop
|
|
47
|
-
- Uses GSAP for smooth animations
|
|
48
|
-
- Instant reset at loop endpoints
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
### **2. Pagination Slider**
|
|
53
|
-
|
|
54
|
-
Multi-item slider with page-based navigation.
|
|
55
|
-
|
|
56
|
-
**Required Elements:**
|
|
57
|
-
- `data-hs-slider="pagination"` - Main container
|
|
58
|
-
- `data-hs-slider="pagination-list"` - List of items
|
|
59
|
-
- `data-hs-slider="pagination-next"` - Next page button
|
|
60
|
-
- `data-hs-slider="pagination-previous"` - Previous page button
|
|
61
|
-
|
|
62
|
-
**Optional Elements:**
|
|
63
|
-
- `data-hs-slider="pagination-counter"` - Page counter display
|
|
64
|
-
- `data-hs-slider="pagination-controls"` - Controls container with config
|
|
65
|
-
- `data-hs-slider="dots-wrap"` - Dot navigation container
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## **Configuration**
|
|
70
|
-
|
|
71
|
-
Add to `pagination-controls` element via `data-hs-config`:
|
|
72
|
-
|
|
73
|
-
### **Syntax:**
|
|
74
|
-
```
|
|
75
|
-
data-hs-config="[option], [option], ..."
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### **Options:**
|
|
79
|
-
|
|
80
|
-
**Show Items (Desktop):**
|
|
81
|
-
```html
|
|
82
|
-
data-hs-config="show-6"
|
|
83
|
-
```
|
|
84
|
-
Shows 6 items per page on desktop (default: 6)
|
|
85
|
-
|
|
86
|
-
**Show Items (Mobile):**
|
|
87
|
-
```html
|
|
88
|
-
data-hs-config="show-3-mobile"
|
|
89
|
-
```
|
|
90
|
-
Shows 3 items per page on mobile (default: desktop value)
|
|
91
|
-
|
|
92
|
-
**Infinite Mode:**
|
|
93
|
-
```html
|
|
94
|
-
data-hs-config="infinite"
|
|
95
|
-
```
|
|
96
|
-
Disables pagination completely (hides controls and dots)
|
|
97
|
-
|
|
98
|
-
**Combined Example:**
|
|
99
|
-
```html
|
|
100
|
-
<div data-hs-slider="pagination-controls" data-hs-config="show-6, show-3-mobile">
|
|
101
|
-
<!-- Controls -->
|
|
102
|
-
</div>
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## **Pagination Example**
|
|
108
|
-
|
|
109
|
-
```html
|
|
110
|
-
<div data-hs-slider="pagination">
|
|
111
|
-
<!-- List wrapper (auto-managed) -->
|
|
112
|
-
<div>
|
|
113
|
-
<div data-hs-slider="pagination-list">
|
|
114
|
-
<div>Item 1</div>
|
|
115
|
-
<div>Item 2</div>
|
|
116
|
-
<div>Item 3</div>
|
|
117
|
-
<div>Item 4</div>
|
|
118
|
-
<div>Item 5</div>
|
|
119
|
-
<div>Item 6</div>
|
|
120
|
-
<div>Item 7</div>
|
|
121
|
-
<div>Item 8</div>
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
|
|
125
|
-
<!-- Controls -->
|
|
126
|
-
<div data-hs-slider="pagination-controls" data-hs-config="show-4, show-2-mobile">
|
|
127
|
-
<button data-hs-slider="pagination-previous">Previous</button>
|
|
128
|
-
<div data-hs-slider="pagination-counter">1 / 2</div>
|
|
129
|
-
<button data-hs-slider="pagination-next">Next</button>
|
|
130
|
-
</div>
|
|
131
|
-
|
|
132
|
-
<!-- Dot navigation -->
|
|
133
|
-
<div data-hs-slider="dots-wrap">
|
|
134
|
-
<div class="dot"></div> <!-- Template (active) -->
|
|
135
|
-
<div class="dot"></div> <!-- Template (inactive) -->
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## **Dot Navigation**
|
|
143
|
-
|
|
144
|
-
### **Setup:**
|
|
145
|
-
1. Add `data-hs-slider="dots-wrap"` container
|
|
146
|
-
2. Include template dots as children
|
|
147
|
-
3. First dot with `is-active` class = active template
|
|
148
|
-
4. Second dot without class = inactive template
|
|
149
|
-
|
|
150
|
-
### **Behavior:**
|
|
151
|
-
- Dots auto-generated for each page
|
|
152
|
-
- Click or press Enter/Space to navigate
|
|
153
|
-
- Active dot gets `is-active` class and `aria-current="page"`
|
|
154
|
-
- Hidden when only 1 page or infinite mode
|
|
155
|
-
|
|
156
|
-
### **Example:**
|
|
157
|
-
```html
|
|
158
|
-
<div data-hs-slider="dots-wrap">
|
|
159
|
-
<div class="dot is-active"></div> <!-- Active template -->
|
|
160
|
-
<div class="dot"></div> <!-- Inactive template -->
|
|
161
|
-
</div>
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
---
|
|
165
|
-
|
|
166
|
-
## **Responsive Breakpoints**
|
|
167
|
-
|
|
168
|
-
Uses CSS custom property `--data-hs-break` to detect layout:
|
|
169
|
-
|
|
170
|
-
```css
|
|
171
|
-
.pagination-list {
|
|
172
|
-
--data-hs-break: "desktop";
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
@media (max-width: 768px) {
|
|
176
|
-
.pagination-list {
|
|
177
|
-
--data-hs-break: "mobile";
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
When breakpoint changes:
|
|
183
|
-
- Re-calculates items per page
|
|
184
|
-
- Re-generates pagination
|
|
185
|
-
- Maintains current position when possible
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## **Keyboard Navigation**
|
|
190
|
-
|
|
191
|
-
All controls support keyboard:
|
|
192
|
-
- `Tab`: Navigate between controls
|
|
193
|
-
- `Enter/Space`: Activate buttons and dots
|
|
194
|
-
- Focus managed with `inert` attribute on inactive pages
|
|
195
|
-
|
|
196
|
-
---
|
|
197
|
-
|
|
198
|
-
## **Accessibility Features**
|
|
199
|
-
|
|
200
|
-
### **ARIA Attributes:**
|
|
201
|
-
- `aria-label` on all buttons
|
|
202
|
-
- `aria-live="polite"` on counter
|
|
203
|
-
- `aria-current="page"` on active dot
|
|
204
|
-
- `aria-hidden` on hidden controls/dots
|
|
205
|
-
|
|
206
|
-
### **Screen Reader Announcements:**
|
|
207
|
-
- Page changes announced via live region
|
|
208
|
-
- Format: "Page X of Y"
|
|
209
|
-
- Temporary announcement (clears after 1s)
|
|
210
|
-
|
|
211
|
-
### **Focus Management:**
|
|
212
|
-
- Uses `inert` attribute on inactive pages
|
|
213
|
-
- Prevents tab navigation to hidden content
|
|
214
|
-
- Focus maintained on controls during navigation
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
## **Pagination Behavior**
|
|
219
|
-
|
|
220
|
-
### **Single Page:**
|
|
221
|
-
- Controls and dots hidden
|
|
222
|
-
- All items visible
|
|
223
|
-
- No interaction needed
|
|
224
|
-
|
|
225
|
-
### **Multiple Pages:**
|
|
226
|
-
- Infinite loop (last page → first page)
|
|
227
|
-
- Clones pages at start/end for seamless loop
|
|
228
|
-
- Instant position reset at boundaries
|
|
229
|
-
- Smooth CSS transitions between pages
|
|
230
|
-
|
|
231
|
-
### **Mobile Scroll:**
|
|
232
|
-
On mobile, after page change:
|
|
233
|
-
- Auto-scrolls to show controls
|
|
234
|
-
- 5rem clearance from bottom
|
|
235
|
-
- Smooth scroll behavior
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
## **How It Works**
|
|
240
|
-
|
|
241
|
-
### **Infinite Carousel:**
|
|
242
|
-
1. Clones first/last slides
|
|
243
|
-
2. Positions wrapper at slide 1 (middle)
|
|
244
|
-
3. On next/prev, animates to target
|
|
245
|
-
4. On loop, instantly resets position
|
|
246
|
-
5. Uses GSAP for smooth animations
|
|
247
|
-
|
|
248
|
-
### **Pagination:**
|
|
249
|
-
1. Calculates total pages based on config
|
|
250
|
-
2. Splits items into page lists
|
|
251
|
-
3. Clones pages for infinite loop
|
|
252
|
-
4. Positions wrapper at page 1 (middle)
|
|
253
|
-
5. On navigate, transitions to target page
|
|
254
|
-
6. On loop, instantly resets to real page
|
|
255
|
-
7. Manages height based on active page
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
|
|
259
|
-
## **Edge Cases**
|
|
260
|
-
|
|
261
|
-
### **No Items:**
|
|
262
|
-
- Early exit, no initialization
|
|
263
|
-
|
|
264
|
-
### **Single Item (Pagination):**
|
|
265
|
-
- No controls shown
|
|
266
|
-
- Single item displayed
|
|
267
|
-
- No pagination needed
|
|
268
|
-
|
|
269
|
-
### **Infinite Mode:**
|
|
270
|
-
- Controls completely hidden
|
|
271
|
-
- Dots completely hidden
|
|
272
|
-
- List displayed as-is
|
|
273
|
-
- No pagination logic runs
|
|
274
|
-
|
|
275
|
-
### **Layout Changes:**
|
|
276
|
-
- ResizeObserver detects breakpoint changes
|
|
277
|
-
- Re-initializes pagination with new item count
|
|
278
|
-
- Tries to maintain current page position
|
|
279
|
-
|
|
280
|
-
---
|
|
281
|
-
|
|
282
|
-
## **Performance**
|
|
283
|
-
|
|
284
|
-
- Uses CSS custom properties for breakpoint detection
|
|
285
|
-
- ResizeObserver for efficient layout monitoring
|
|
286
|
-
- Inert attribute prevents unnecessary focus handling
|
|
287
|
-
- Cleanup on destroy for Barba.js compatibility
|
|
288
|
-
- Efficient DOM cloning and manipulation
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
## **Notes**
|
|
293
|
-
|
|
294
|
-
- Requires GSAP for infinite carousel animations
|
|
295
|
-
- CSS transitions handle pagination animations
|
|
296
|
-
- Each pagination container is independent
|
|
297
|
-
- Dot templates must exist before initialization
|
|
298
|
-
- Mobile breakpoint detected via CSS custom property
|
|
299
|
-
- All event listeners cleaned up on destroy
|