Skip to content

Commit ab98c96

Browse files
committed
Bump to 2.0
1 parent 6d865c0 commit ab98c96

5 files changed

+21
-12
lines changed

jquery.smooth-scroll.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery Smooth Scroll - v1.7.2 - 2016-01-23
2+
* jQuery Smooth Scroll - v2.0.0 - 2016-07-31
33
* https://github.com/kswedberg/jquery-smooth-scroll
44
* Copyright (c) 2016 Karl Swedberg
55
* Licensed MIT
@@ -18,7 +18,7 @@
1818
}
1919
}(function($) {
2020

21-
var version = '1.7.2';
21+
var version = '2.0.0';
2222
var optionOverrides = {};
2323
var defaults = {
2424
exclude: [],
@@ -46,7 +46,14 @@
4646
// fn(opts) function to be called after scrolling occurs.
4747
// `this` is the triggering element
4848
afterScroll: function() {},
49+
50+
// easing name. jQuery comes with "swing" and "linear." For others, you'll need an easing plugin
51+
// from jQuery UI or elsewhere
4952
easing: 'swing',
53+
54+
// speed can be a number or 'auto'
55+
// if 'auto', the speed will be calculated based on the formula:
56+
// (current scroll position - target scroll position) / autoCoeffic
5057
speed: 400,
5158

5259
// coefficient for "auto" speed
@@ -203,12 +210,12 @@
203210

204211
if (options.delegateSelector !== null) {
205212
this
206-
.undelegate(options.delegateSelector, 'click.smoothscroll')
207-
.delegate(options.delegateSelector, 'click.smoothscroll', clickHandler);
213+
.off('click.smoothscroll', options.delegateSelector)
214+
.on('click.smoothscroll', options.delegateSelector, clickHandler);
208215
} else {
209216
this
210-
.unbind('click.smoothscroll')
211-
.bind('click.smoothscroll', clickHandler);
217+
.off('click.smoothscroll')
218+
.on('click.smoothscroll', clickHandler);
212219
}
213220

214221
return this;

jquery.smooth-scroll.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-smooth-scroll",
33
"title": "jQuery Smooth Scroll",
4-
"version": "1.7.2",
4+
"version": "2.0.0",
55
"scripts": {},
66
"main": "jquery.smooth-scroll.js",
77
"author": {

readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Allows for easy implementation of smooth scrolling for same-page links.
44

55
[![NPM](https://nodei.co/npm/jquery-smooth-scroll.png?compact=true)](https://npmjs.org/package/jquery-smooth-scroll)
66

7+
Note: Version 2.0+ of this plugin requires jQuery version 1.7 or greater.
8+
79
## Download
810

911
Using npm:
@@ -144,7 +146,7 @@ for `$.smoothScroll`:
144146

145147
### Smooth scrolling on page load
146148

147-
If you want to scroll to an element when the page loads, use `$.smoothScroll()` in a script at the end of the body or use `$(document).ready()`. To prevent the browser from automatically scrolling to the element on its own, your link on page 1 will need to include a fragment identifier that does _not_ match an element id on page 2. To ensure that users without JavaScript get to the same element, you should modify the link's hash on page 1 with JavaScript. Your script on page 2 will then modify it back to the correct one when you call `$.smoothScroll()`.
149+
If you want to scroll to an element when the page loads, use `$.smoothScroll()` in a script at the end of the body or use `$(document).ready()`. To prevent the browser from automatically scrolling to the element on its own, your link on page 1 will need to include a fragment identifier that does _not_ match an element id on page 2. To ensure that users without JavaScript get to the same element, you should modify the link's hash on page 1 with JavaScript. Your script on page 2 will then modify it back to the correct one when you call `$.smoothScroll()`.
148150

149151
For example, let's say you want to smooth scroll to `<div id="scrolltome"></div>` on page-2.html. For page-1.html, your script might do the following:
150152

@@ -157,7 +159,7 @@ $('a[href="page-2.html#scrolltome"]').attr('href', function() {
157159

158160
```
159161

160-
Then for page-2.html, your script would do this:
162+
Then for page-2.html, your script would do this:
161163

162164
```js
163165
// Call $.smoothScroll if location.hash starts with "#smoothScroll"

src/jquery.smooth-scroll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(function($) {
2-
var version = '1.7.2';
2+
var version = '2.0.0';
33
var optionOverrides = {};
44
var defaults = {
55
exclude: [],

0 commit comments

Comments
 (0)