@hortonstudio/main 1.9.20 → 1.9.22
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/dist/assets/animations-igIF6V0K.js +3 -0
- package/dist/assets/animations-igIF6V0K.js. +3 -0
- package/dist/assets/animations-igIF6V0K.js.gz +0 -0
- package/dist/assets/animations-igIF6V0K.js.map +1 -0
- package/dist/assets/counter-B9xmgh8V.js +2 -0
- package/dist/assets/counter-B9xmgh8V.js. +2 -0
- package/dist/assets/counter-B9xmgh8V.js.gz +0 -0
- package/dist/assets/counter-B9xmgh8V.js.map +1 -0
- package/dist/assets/cssVariables-n9wQSSYb.js +2 -0
- package/dist/assets/cssVariables-n9wQSSYb.js.map +1 -0
- package/dist/assets/default-CZ6vle49.js +2 -0
- package/dist/assets/default-CZ6vle49.js. +2 -0
- package/dist/assets/default-CZ6vle49.js.gz +0 -0
- package/dist/assets/default-CZ6vle49.js.map +1 -0
- package/dist/assets/modalManager-LtDi9OJz.js +2 -0
- package/dist/assets/modalManager-LtDi9OJz.js. +2 -0
- package/dist/assets/modalManager-LtDi9OJz.js.gz +0 -0
- package/dist/assets/modalManager-LtDi9OJz.js.map +1 -0
- package/dist/assets/normalize-DWI4olFS.js +2 -0
- package/dist/assets/normalize-DWI4olFS.js. +2 -0
- package/dist/assets/normalize-DWI4olFS.js.gz +0 -0
- package/dist/assets/normalize-DWI4olFS.js.map +1 -0
- package/dist/assets/structure--7b3v7AH.js +2 -0
- package/dist/assets/structure--7b3v7AH.js. +2 -0
- package/dist/assets/structure--7b3v7AH.js.gz +0 -0
- package/dist/assets/structure--7b3v7AH.js.map +1 -0
- package/dist/assets/utils-DA-PANmk.js +2 -0
- package/dist/assets/utils-DA-PANmk.js.map +1 -0
- package/dist/bootstrap.js +2 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/main.js +3 -0
- package/dist/main.js. +3 -0
- package/dist/main.js.gz +0 -0
- package/dist/main.js.map +1 -0
- package/package.json +5 -2
- package/.prettierrc +0 -8
- package/eslint.config.js +0 -32
- package/index.ts +0 -275
- package/public/bootstrap.js +0 -16
- package/src/animations/animations.ts +0 -93
- package/src/animations/functions/counter/counter.ts +0 -137
- package/src/config.json +0 -570
- package/src/config.ts +0 -105
- package/src/modules/default/README.md +0 -167
- package/src/modules/default/default.ts +0 -71
- package/src/modules/default/functions/accessibility/README.md +0 -134
- package/src/modules/default/functions/accessibility/accessibility.ts +0 -54
- package/src/modules/default/functions/accordion/README.md +0 -451
- package/src/modules/default/functions/accordion/accordion.ts +0 -189
- package/src/modules/default/functions/comparison/comparison.ts +0 -424
- package/src/modules/default/functions/marquee/marquee.ts +0 -206
- package/src/modules/default/functions/navbar/README.md +0 -393
- package/src/modules/default/functions/navbar/functions/arrow-navigation/arrow-navigation.ts +0 -183
- package/src/modules/default/functions/navbar/functions/dropdown/dropdown.ts +0 -313
- package/src/modules/default/functions/navbar/functions/menu/menu.ts +0 -315
- package/src/modules/default/functions/navbar/navbar.ts +0 -51
- package/src/modules/default/functions/smooth-scroll/README.md +0 -417
- package/src/modules/default/functions/smooth-scroll/smooth-scroll.ts +0 -115
- package/src/modules/default/functions/transition/README.md +0 -328
- package/src/modules/default/functions/transition/transition.ts +0 -290
- package/src/modules/normalize/README.md +0 -172
- package/src/modules/normalize/functions/clickable/README.md +0 -84
- package/src/modules/normalize/functions/clickable/clickable.ts +0 -43
- package/src/modules/normalize/functions/clickable/functions/normalize/README.md +0 -213
- package/src/modules/normalize/functions/clickable/functions/normalize/normalize.ts +0 -68
- package/src/modules/normalize/functions/dupe/README.md +0 -405
- package/src/modules/normalize/functions/dupe/dupe.ts +0 -197
- package/src/modules/normalize/functions/sync/sync.ts +0 -378
- package/src/modules/normalize/normalize.ts +0 -58
- package/src/modules/structure/README.md +0 -190
- package/src/modules/structure/functions/form/README.md +0 -94
- package/src/modules/structure/functions/form/form.ts +0 -54
- package/src/modules/structure/functions/form/functions/honeypot/README.md +0 -77
- package/src/modules/structure/functions/form/functions/honeypot/honeypot.ts +0 -37
- package/src/modules/structure/functions/form/functions/range/README.md +0 -410
- package/src/modules/structure/functions/form/functions/range/range.ts +0 -92
- package/src/modules/structure/functions/form/functions/select/README.md +0 -393
- package/src/modules/structure/functions/form/functions/select/functions/custom-select/custom-select.ts +0 -637
- package/src/modules/structure/functions/form/functions/select/functions/states/states.ts +0 -118
- package/src/modules/structure/functions/form/functions/select/select.ts +0 -48
- package/src/modules/structure/functions/form/functions/test/test.ts +0 -132
- package/src/modules/structure/functions/pagination/README.md +0 -527
- package/src/modules/structure/functions/pagination/pagination.ts +0 -493
- package/src/modules/structure/functions/site-settings/README.md +0 -395
- package/src/modules/structure/functions/site-settings/site-settings.ts +0 -158
- package/src/modules/structure/functions/toc/README.md +0 -82
- package/src/modules/structure/functions/toc/functions/heading-links/heading-links.ts +0 -171
- package/src/modules/structure/functions/toc/functions/progress-bar/progress-bar.ts +0 -101
- package/src/modules/structure/functions/toc/toc.ts +0 -35
- package/src/modules/structure/functions/year-replacement/README.md +0 -55
- package/src/modules/structure/functions/year-replacement/year-replacement.ts +0 -59
- package/src/modules/structure/structure.ts +0 -59
- package/src/utils/attributeSelector.ts +0 -78
- package/src/utils/cssVariables.ts +0 -24
- package/src/utils/gsap.ts +0 -198
- package/src/utils/heightAnimator.ts +0 -130
- package/src/utils/modalManager.ts +0 -150
- package/src/utils.ts +0 -54
- package/tsconfig.json +0 -24
- package/vite.config.js +0 -45
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
# **Smooth Scroll System Documentation**
|
|
2
|
-
|
|
3
|
-
## **Overview**
|
|
4
|
-
|
|
5
|
-
The smooth scroll system provides GSAP-powered smooth scrolling for anchor links, replacing Webflow's default behavior with a more customizable solution. It supports scroll offsets, reduced motion preferences, and automatically triggers scroll-based animations on page load.
|
|
6
|
-
|
|
7
|
-
**Note:** This module auto-initializes on every page load.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## **Smooth Scroll**
|
|
12
|
-
|
|
13
|
-
### **Required Dependencies**
|
|
14
|
-
|
|
15
|
-
**GSAP Core**
|
|
16
|
-
|
|
17
|
-
- Must be loaded before this script
|
|
18
|
-
|
|
19
|
-
**GSAP ScrollToPlugin**
|
|
20
|
-
|
|
21
|
-
- Required for smooth scrolling functionality
|
|
22
|
-
|
|
23
|
-
**Typical setup:**
|
|
24
|
-
|
|
25
|
-
```html
|
|
26
|
-
<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js"></script>
|
|
27
|
-
<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollToPlugin.min.js"></script>
|
|
28
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@hortonstudio/main@latest"></script>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### **What It Does**
|
|
32
|
-
|
|
33
|
-
1. **Disables native smooth scroll** - Removes Webflow's jQuery-based anchor link handler
|
|
34
|
-
2. **Disables CSS smooth scrolling** - Sets `scroll-behavior: auto` on html and body
|
|
35
|
-
3. **GSAP smooth scrolling** - Uses GSAP ScrollToPlugin for animated scrolling
|
|
36
|
-
4. **Respects reduced motion** - Instant scroll if user has `prefers-reduced-motion` enabled
|
|
37
|
-
5. **Custom offset support** - Reads `--misc--scroll-offset` CSS variable for scroll offset
|
|
38
|
-
6. **Focus management** - Sets focus on target element after scroll
|
|
39
|
-
7. **URL hash updates** - Updates browser URL with hash when scrolling to anchor
|
|
40
|
-
8. **Mock scroll trigger** - Triggers scroll-based animations on page load with quick scroll
|
|
41
|
-
9. **Keyboard support** - Handles Enter/Space key activation on anchor links
|
|
42
|
-
|
|
43
|
-
### **When It Runs**
|
|
44
|
-
|
|
45
|
-
- Auto-initializes on page load
|
|
46
|
-
- Runs on every page in a multi-page site
|
|
47
|
-
- Listed in `autoInitModules` in index.js
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## **Scroll Offset**
|
|
52
|
-
|
|
53
|
-
### **CSS Variable**
|
|
54
|
-
|
|
55
|
-
Define a scroll offset using a CSS custom property:
|
|
56
|
-
|
|
57
|
-
```css
|
|
58
|
-
:root {
|
|
59
|
-
--misc--scroll-offset: 100px;
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**What it does:** When scrolling to an anchor, the page scrolls to the target element minus this offset. Useful for fixed headers.
|
|
64
|
-
|
|
65
|
-
**Default:** `0` (no offset)
|
|
66
|
-
|
|
67
|
-
**Units:** Pixels only (parsed as integer)
|
|
68
|
-
|
|
69
|
-
### **Example with Fixed Header**
|
|
70
|
-
|
|
71
|
-
```css
|
|
72
|
-
:root {
|
|
73
|
-
--misc--scroll-offset: 80px; /* Height of fixed navbar */
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**Result:** When clicking an anchor link, the page scrolls so the target element is 80px from the top of the viewport.
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## **Anchor Links**
|
|
82
|
-
|
|
83
|
-
### **Supported Anchor Links**
|
|
84
|
-
|
|
85
|
-
Any link with `href` starting with `#`:
|
|
86
|
-
|
|
87
|
-
```html
|
|
88
|
-
<a href="#section-1">Go to Section 1</a>
|
|
89
|
-
<a href="#about">About Us</a>
|
|
90
|
-
<a href="#contact">Contact</a>
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Requirements:**
|
|
94
|
-
|
|
95
|
-
- Must have `href` attribute starting with `#`
|
|
96
|
-
- Target element must have matching `id` attribute
|
|
97
|
-
- Cannot be just `#` (empty hash)
|
|
98
|
-
|
|
99
|
-
### **Target Elements**
|
|
100
|
-
|
|
101
|
-
```html
|
|
102
|
-
<section id="section-1">
|
|
103
|
-
<h2>Section 1</h2>
|
|
104
|
-
</section>
|
|
105
|
-
|
|
106
|
-
<div id="about">
|
|
107
|
-
<h2>About Us</h2>
|
|
108
|
-
</div>
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
**Requirements:**
|
|
112
|
-
|
|
113
|
-
- Must have `id` attribute matching the anchor's `href` (without `#`)
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## **Animation Settings**
|
|
118
|
-
|
|
119
|
-
### **GSAP Configuration**
|
|
120
|
-
|
|
121
|
-
The scroll animation uses these GSAP settings:
|
|
122
|
-
|
|
123
|
-
**Duration:** `1` second
|
|
124
|
-
**Easing:** `power2.out` (fast start, slow end)
|
|
125
|
-
**Plugin:** ScrollToPlugin with `offsetY` support
|
|
126
|
-
|
|
127
|
-
### **Example of smooth scroll behavior:**
|
|
128
|
-
|
|
129
|
-
```javascript
|
|
130
|
-
gsap.to(window, {
|
|
131
|
-
duration: 1,
|
|
132
|
-
scrollTo: {
|
|
133
|
-
y: target,
|
|
134
|
-
offsetY: offset,
|
|
135
|
-
},
|
|
136
|
-
ease: 'power2.out',
|
|
137
|
-
});
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**Result:** Smooth 1-second scroll with deceleration easing.
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## **Reduced Motion Support**
|
|
145
|
-
|
|
146
|
-
### **What It Does**
|
|
147
|
-
|
|
148
|
-
If user has `prefers-reduced-motion: reduce` enabled:
|
|
149
|
-
|
|
150
|
-
- Skips GSAP animation entirely
|
|
151
|
-
- Uses instant scroll with `window.scrollTo()`
|
|
152
|
-
- Still respects scroll offset
|
|
153
|
-
- Still sets focus on target element
|
|
154
|
-
|
|
155
|
-
### **Detection**
|
|
156
|
-
|
|
157
|
-
```javascript
|
|
158
|
-
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**Result:** Users with motion sensitivity get instant, non-animated scrolling while maintaining all functionality.
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## **Focus Management**
|
|
166
|
-
|
|
167
|
-
### **Automatic Focus**
|
|
168
|
-
|
|
169
|
-
After scrolling to target element:
|
|
170
|
-
|
|
171
|
-
1. Sets `tabindex="-1"` on target (makes it focusable without adding to tab order)
|
|
172
|
-
2. Calls `focus({ preventScroll: true })` on target
|
|
173
|
-
3. Announces target to screen readers
|
|
174
|
-
|
|
175
|
-
**Why:** Improves accessibility by moving keyboard focus to the section you scrolled to, similar to native anchor link behavior.
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## **Mock Scroll (Animation Trigger)**
|
|
180
|
-
|
|
181
|
-
### **What It Does**
|
|
182
|
-
|
|
183
|
-
On page load, performs a quick scroll:
|
|
184
|
-
|
|
185
|
-
1. Scrolls to `1px`
|
|
186
|
-
2. Immediately scrolls back to `0px`
|
|
187
|
-
|
|
188
|
-
**Why:** Triggers scroll-based animations (IntersectionObserver, scroll triggers) that only fire when the page scrolls.
|
|
189
|
-
|
|
190
|
-
**Condition:** Only runs if page is scrollable (`document.body.scrollHeight > window.innerHeight`)
|
|
191
|
-
|
|
192
|
-
**Result:** Scroll-based animations initialize properly on page load without user interaction.
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
## **URL Hash Updates**
|
|
197
|
-
|
|
198
|
-
When clicking an anchor link:
|
|
199
|
-
|
|
200
|
-
1. Prevents default browser behavior
|
|
201
|
-
2. Updates URL hash using `history.replaceState()`
|
|
202
|
-
3. Scrolls to target
|
|
203
|
-
|
|
204
|
-
**Example:**
|
|
205
|
-
|
|
206
|
-
- Click `<a href="#about">`
|
|
207
|
-
- URL changes from `example.com` to `example.com#about`
|
|
208
|
-
- Page smoothly scrolls to `#about` element
|
|
209
|
-
|
|
210
|
-
**Note:** Uses `replaceState` (not `pushState`), so it doesn't create a new browser history entry.
|
|
211
|
-
|
|
212
|
-
---
|
|
213
|
-
|
|
214
|
-
## **Keyboard Support**
|
|
215
|
-
|
|
216
|
-
### **Supported Keys**
|
|
217
|
-
|
|
218
|
-
When an anchor link is focused:
|
|
219
|
-
|
|
220
|
-
- **Enter** � Triggers smooth scroll to target
|
|
221
|
-
- **Space** � Triggers smooth scroll to target
|
|
222
|
-
|
|
223
|
-
**Implementation:** Keyboard events are handled the same as clicks, providing consistent behavior.
|
|
224
|
-
|
|
225
|
-
---
|
|
226
|
-
|
|
227
|
-
## **Usage Examples**
|
|
228
|
-
|
|
229
|
-
### **Basic Anchor Link**
|
|
230
|
-
|
|
231
|
-
```html
|
|
232
|
-
<nav>
|
|
233
|
-
<a href="#section-1">Section 1</a>
|
|
234
|
-
<a href="#section-2">Section 2</a>
|
|
235
|
-
</nav>
|
|
236
|
-
|
|
237
|
-
<section id="section-1">
|
|
238
|
-
<h2>Section 1</h2>
|
|
239
|
-
<p>Content here...</p>
|
|
240
|
-
</section>
|
|
241
|
-
|
|
242
|
-
<section id="section-2">
|
|
243
|
-
<h2>Section 2</h2>
|
|
244
|
-
<p>More content...</p>
|
|
245
|
-
</section>
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
**Result:** Clicking links smoothly scrolls to corresponding sections with 1-second animation.
|
|
249
|
-
|
|
250
|
-
### **With Scroll Offset**
|
|
251
|
-
|
|
252
|
-
```css
|
|
253
|
-
:root {
|
|
254
|
-
--misc--scroll-offset: 100px;
|
|
255
|
-
}
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
```html
|
|
259
|
-
<header style="position: fixed; height: 100px;">
|
|
260
|
-
<nav>
|
|
261
|
-
<a href="#content">Skip to content</a>
|
|
262
|
-
</nav>
|
|
263
|
-
</header>
|
|
264
|
-
|
|
265
|
-
<main id="content" style="margin-top: 100px;">
|
|
266
|
-
<h1>Main Content</h1>
|
|
267
|
-
</main>
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
**Result:** Clicking "Skip to content" scrolls so the main content appears 100px from top (below the fixed header).
|
|
271
|
-
|
|
272
|
-
### **Table of Contents**
|
|
273
|
-
|
|
274
|
-
```html
|
|
275
|
-
<nav class="toc">
|
|
276
|
-
<a href="#introduction">Introduction</a>
|
|
277
|
-
<a href="#features">Features</a>
|
|
278
|
-
<a href="#installation">Installation</a>
|
|
279
|
-
<a href="#usage">Usage</a>
|
|
280
|
-
</nav>
|
|
281
|
-
|
|
282
|
-
<article>
|
|
283
|
-
<section id="introduction">
|
|
284
|
-
<h2>Introduction</h2>
|
|
285
|
-
</section>
|
|
286
|
-
|
|
287
|
-
<section id="features">
|
|
288
|
-
<h2>Features</h2>
|
|
289
|
-
</section>
|
|
290
|
-
|
|
291
|
-
<section id="installation">
|
|
292
|
-
<h2>Installation</h2>
|
|
293
|
-
</section>
|
|
294
|
-
|
|
295
|
-
<section id="usage">
|
|
296
|
-
<h2>Usage</h2>
|
|
297
|
-
</section>
|
|
298
|
-
</article>
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
**Result:** Fully functional table of contents with smooth scrolling and focus management.
|
|
302
|
-
|
|
303
|
-
---
|
|
304
|
-
|
|
305
|
-
## **Webflow Integration**
|
|
306
|
-
|
|
307
|
-
### **Disables Webflow's Default Behavior**
|
|
308
|
-
|
|
309
|
-
This script automatically disables:
|
|
310
|
-
|
|
311
|
-
1. **jQuery scroll handler** - Removes `click.wf-scroll` event listener
|
|
312
|
-
2. **CSS smooth scrolling** - Sets `scroll-behavior: auto`
|
|
313
|
-
|
|
314
|
-
**When:** On Webflow ready (`afterWebflowReady()` callback)
|
|
315
|
-
|
|
316
|
-
**Why:** Prevents conflicts between Webflow's scroll and GSAP scroll.
|
|
317
|
-
|
|
318
|
-
---
|
|
319
|
-
|
|
320
|
-
## **Key Attributes Summary**
|
|
321
|
-
|
|
322
|
-
This module doesn't require any data attributes - it works automatically with standard HTML anchor links.
|
|
323
|
-
|
|
324
|
-
| Element | Requirement |
|
|
325
|
-
| -------------- | ------------------- |
|
|
326
|
-
| Anchor link | `href="#target-id"` |
|
|
327
|
-
| Target element | `id="target-id"` |
|
|
328
|
-
|
|
329
|
-
---
|
|
330
|
-
|
|
331
|
-
## **API**
|
|
332
|
-
|
|
333
|
-
This module has no public API methods. It runs automatically and handles all anchor links on the page.
|
|
334
|
-
|
|
335
|
-
---
|
|
336
|
-
|
|
337
|
-
## **Notes**
|
|
338
|
-
|
|
339
|
-
1. **GSAP required** - Must load GSAP and ScrollToPlugin before this script
|
|
340
|
-
2. **Auto-initializes** - Runs on every page load
|
|
341
|
-
3. **Disables Webflow scroll** - Replaces Webflow's default anchor link behavior
|
|
342
|
-
4. **Accessibility first** - Respects reduced motion, manages focus
|
|
343
|
-
5. **No configuration** - Works out of the box with standard HTML
|
|
344
|
-
6. **CSS variable for offset** - Use `--misc--scroll-offset` for custom offset
|
|
345
|
-
7. **Mock scroll triggers animations** - Ensures scroll-based animations initialize
|
|
346
|
-
8. **Clean destroy** - Removes listeners and re-enables CSS smooth scrolling on cleanup
|
|
347
|
-
|
|
348
|
-
---
|
|
349
|
-
|
|
350
|
-
## **v2.0.0 Improvements**
|
|
351
|
-
|
|
352
|
-
### **JSON Config System**
|
|
353
|
-
|
|
354
|
-
- Added config.js with module metadata
|
|
355
|
-
- Future-proof: Ready for configuration options if needed
|
|
356
|
-
- Note: This module auto-detects anchor links and requires no data attributes
|
|
357
|
-
|
|
358
|
-
### **Barba.js / SPA Compatibility**
|
|
359
|
-
|
|
360
|
-
The smooth-scroll system is fully compatible with Barba.js and other SPA frameworks:
|
|
361
|
-
|
|
362
|
-
- Proper cleanup on destroy (removes event listeners, restores CSS scroll behavior)
|
|
363
|
-
- Fresh initialization on reinitialize
|
|
364
|
-
- Works on all anchor links on new pages
|
|
365
|
-
- Works like fresh page load on new DOM
|
|
366
|
-
|
|
367
|
-
---
|
|
368
|
-
|
|
369
|
-
## **Common Issues**
|
|
370
|
-
|
|
371
|
-
**Smooth scroll not working:**
|
|
372
|
-
|
|
373
|
-
1. Verify GSAP and ScrollToPlugin are loaded before main script
|
|
374
|
-
2. Check browser console for GSAP errors
|
|
375
|
-
3. Ensure anchor `href` starts with `#` and matches target `id`
|
|
376
|
-
4. Verify target element exists in DOM
|
|
377
|
-
|
|
378
|
-
**Scroll offset not working:**
|
|
379
|
-
|
|
380
|
-
1. Check CSS variable is defined: `--misc--scroll-offset: 100px`
|
|
381
|
-
2. Verify it's on `:root` or `html` element (computed style)
|
|
382
|
-
3. Ensure value is in pixels (no other units supported)
|
|
383
|
-
4. Check computed styles in browser DevTools
|
|
384
|
-
|
|
385
|
-
**Focus not working after scroll:**
|
|
386
|
-
|
|
387
|
-
1. This is expected behavior for accessibility
|
|
388
|
-
2. Target element gets `tabindex="-1"` and focus
|
|
389
|
-
3. Use CSS to style `:focus` state if needed
|
|
390
|
-
4. Don't prevent this - it's important for screen reader users
|
|
391
|
-
|
|
392
|
-
**Scroll animations not triggering on load:**
|
|
393
|
-
|
|
394
|
-
1. Mock scroll only runs if page is scrollable
|
|
395
|
-
2. Check that `document.body.scrollHeight > window.innerHeight`
|
|
396
|
-
3. If page isn't tall enough, animations may not trigger
|
|
397
|
-
4. Add more content or adjust animation triggers
|
|
398
|
-
|
|
399
|
-
**Reduced motion not instant:**
|
|
400
|
-
|
|
401
|
-
1. Check browser/OS motion settings
|
|
402
|
-
2. Test with DevTools: Rendering � Emulate CSS media `prefers-reduced-motion: reduce`
|
|
403
|
-
3. Verify scroll is instant (no animation)
|
|
404
|
-
|
|
405
|
-
**URL hash not updating:**
|
|
406
|
-
|
|
407
|
-
1. Check `history.replaceState` is supported (all modern browsers)
|
|
408
|
-
2. Verify no errors in console
|
|
409
|
-
3. Ensure target element has `id` attribute
|
|
410
|
-
4. Check that link click isn't being prevented elsewhere
|
|
411
|
-
|
|
412
|
-
**Conflicts with other scroll libraries:**
|
|
413
|
-
|
|
414
|
-
1. This module disables Webflow's scroll on init
|
|
415
|
-
2. If using Lenis or other smooth scroll libraries, may conflict
|
|
416
|
-
3. Choose one smooth scroll solution per site
|
|
417
|
-
4. Remove this module if using another smooth scroll library
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { getGsap, prefersReducedMotion } from '@utils';
|
|
2
|
-
|
|
3
|
-
export async function init() {
|
|
4
|
-
// Store event handlers for cleanup
|
|
5
|
-
let clickHandler = null;
|
|
6
|
-
let keydownHandler = null;
|
|
7
|
-
|
|
8
|
-
// Disable Webflow's native scroll behavior (jQuery-based)
|
|
9
|
-
// This runs immediately since default module already waits for IX3
|
|
10
|
-
if (typeof $ !== 'undefined') {
|
|
11
|
-
$(document).off('click.wf-scroll');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Disable CSS smooth scrolling
|
|
15
|
-
document.documentElement.style.scrollBehavior = 'auto';
|
|
16
|
-
document.body.style.scrollBehavior = 'auto';
|
|
17
|
-
|
|
18
|
-
function getScrollOffset() {
|
|
19
|
-
const offsetValue = getComputedStyle(document.documentElement)
|
|
20
|
-
.getPropertyValue('--misc--scroll-offset')
|
|
21
|
-
.trim();
|
|
22
|
-
return parseInt(offsetValue) || 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Smooth scroll to element with offset
|
|
26
|
-
function scrollToElement(target, offset = 0) {
|
|
27
|
-
if (!target) return;
|
|
28
|
-
|
|
29
|
-
const gsapLib = getGsap('smooth-scroll', false);
|
|
30
|
-
|
|
31
|
-
// Skip animation if user prefers reduced motion or GSAP not available
|
|
32
|
-
if (prefersReducedMotion() || !gsapLib) {
|
|
33
|
-
const targetPosition = target.getBoundingClientRect().top + window.scrollY - offset;
|
|
34
|
-
window.scrollTo(0, targetPosition);
|
|
35
|
-
target.setAttribute('tabindex', '-1');
|
|
36
|
-
target.focus({ preventScroll: true });
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
gsapLib.gsap.to(window, {
|
|
41
|
-
duration: 1,
|
|
42
|
-
scrollTo: {
|
|
43
|
-
y: target,
|
|
44
|
-
offsetY: offset,
|
|
45
|
-
},
|
|
46
|
-
ease: 'power2.out',
|
|
47
|
-
onComplete: function () {
|
|
48
|
-
target.setAttribute('tabindex', '-1');
|
|
49
|
-
target.focus({ preventScroll: true });
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function handleAnchorActivation(e) {
|
|
55
|
-
const link = e.target.closest('a[href^="#"]');
|
|
56
|
-
if (!link) return;
|
|
57
|
-
|
|
58
|
-
const href = link.getAttribute('href');
|
|
59
|
-
if (!href || href === '#') return;
|
|
60
|
-
|
|
61
|
-
const targetId = href.substring(1);
|
|
62
|
-
const targetElement = document.getElementById(targetId);
|
|
63
|
-
|
|
64
|
-
if (targetElement) {
|
|
65
|
-
e.preventDefault();
|
|
66
|
-
if (history.replaceState) {
|
|
67
|
-
history.replaceState(null, null, `#${targetElement.id}`);
|
|
68
|
-
}
|
|
69
|
-
const offset = getScrollOffset();
|
|
70
|
-
scrollToElement(targetElement, offset);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Handle anchor link clicks and keyboard activation
|
|
75
|
-
function handleAnchorClicks() {
|
|
76
|
-
clickHandler = handleAnchorActivation;
|
|
77
|
-
keydownHandler = function (e) {
|
|
78
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
79
|
-
handleAnchorActivation(e);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
document.addEventListener('click', clickHandler);
|
|
84
|
-
document.addEventListener('keydown', keydownHandler);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Initialize anchor link handling
|
|
88
|
-
handleAnchorClicks();
|
|
89
|
-
|
|
90
|
-
// Mock scroll to trigger scroll-based animations
|
|
91
|
-
const gsapLib = getGsap('smooth-scroll', false);
|
|
92
|
-
if (gsapLib && document.body.scrollHeight > window.innerHeight) {
|
|
93
|
-
gsapLib.gsap.set(window, { scrollTo: 1 });
|
|
94
|
-
gsapLib.gsap.set(window, { scrollTo: 0 });
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
result: 'autoInit-smooth-scroll initialized',
|
|
99
|
-
destroy: () => {
|
|
100
|
-
// Remove event listeners
|
|
101
|
-
if (clickHandler) {
|
|
102
|
-
document.removeEventListener('click', clickHandler);
|
|
103
|
-
clickHandler = null;
|
|
104
|
-
}
|
|
105
|
-
if (keydownHandler) {
|
|
106
|
-
document.removeEventListener('keydown', keydownHandler);
|
|
107
|
-
keydownHandler = null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Re-enable CSS smooth scrolling
|
|
111
|
-
document.documentElement.style.scrollBehavior = '';
|
|
112
|
-
document.body.style.scrollBehavior = '';
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
}
|