You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BREAKING CHANGES:
- Use `hashchange` instead of `pushState` for better browser support
- Remove `updateUrl` option, since URL will always update
- Fixed focus state approach
- Pass Node or Number, not ID string, into `animateScroll` method
- Remove `escapeCharacters` from public API
- If scrolling to top with `#`, add an ID to the body and scroll that way
- Only look for fixed header if a selector for one is set
// You can optionally pass in a y-position to scroll to as an integer
180
182
smoothScroll.animateScroll( 750 );
181
183
```
182
184
183
-
#### escapeCharacters()
184
-
Escape special characters for use with `animateScroll()`.
185
-
186
-
```javascript
187
-
var toggle =smoothScroll.escapeCharacters('#1@#%^-');
188
-
```
189
-
190
185
#### destroy()
191
186
Destroy the current `smoothScroll.init()`. This is called automatically during the `init` function to remove any existing initializations.
192
187
@@ -197,12 +192,20 @@ smoothScroll.destroy();
197
192
198
193
### Fixed Headers
199
194
200
-
Add a `[data-scroll-header]` data attribute to fixed headers. Smooth Scroll will automatically offset scroll distances by the header height. If you have multiple fixed headers, add `[data-scroll-header]` to the last one in the markup.
195
+
If you're using a fixed header, Smooth Scroll will automatically offset scroll distances by the header height. Pass in a valid CSS selector for your fixed header as an option to the `init`.
196
+
197
+
If you have multiple fixed headers, pass in the last one in the markup.
201
198
202
199
```html
203
200
<navdata-scroll-header>
204
201
...
205
202
</nav>
203
+
...
204
+
<script>
205
+
smoothScroll.init({
206
+
selectorHeader:'[data-scroll-header]'
207
+
});
208
+
</script>
206
209
```
207
210
208
211
### Animating links to other pages
@@ -221,10 +224,10 @@ You can attempt to implement it using the API, but it's very difficult to preven
221
224
```html
222
225
<script>
223
226
if ( window.location.hash ) {
224
-
varhash=smoothScroll.escapeCharacters( window.location.hash ); //Escape the hash
225
-
var toggle =document.querySelector( 'a[href*="'+ hash +'"]' ); // Get the toggle (if one exists)
227
+
varanchor=document.querySelector( window.location.hash ); //Get the anchor
228
+
var toggle =document.querySelector( 'a[href*="'+window.location.hash+'"]' ); // Get the toggle (if one exists)
226
229
var options = {}; // Any custom options you want to use would go here
@@ -234,8 +237,7 @@ You can attempt to implement it using the API, but it's very difficult to preven
234
237
235
238
Smooth Scroll works in all modern browsers, and IE 9 and above.
236
239
237
-
Smooth Scroll is built with modern JavaScript APIs, and uses progressive enhancement. If the JavaScript file fails to load, or if your site is viewed on older and less capable browsers, anchor links will jump the way they normally would. If you need to smooth scrolling for older browsers, [download the jQuery version of Smooth Scroll on GitHub](https://github.com/cferdinandi/smooth-scroll/tree/archive-v1).
238
-
240
+
Smooth Scroll is built with modern JavaScript APIs, and uses progressive enhancement. If the JavaScript file fails to load, or if your site is viewed on older and less capable browsers, anchor links will jump the way they normally would.
0 commit comments