Skip to content

Commit eac3d02

Browse files
committed
Add preventDefault option and bump to 1.4.11.
* Closes kswedberg#44
1 parent 2e2206d commit eac3d02

File tree

7 files changed

+33
-14
lines changed

7 files changed

+33
-14
lines changed

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ <h4>Options</h4>
8484
speed: 400,
8585

8686
// coefficient for &quot;auto&quot; speed
87-
autoCoefficent: 2
87+
autoCoefficent: 2,
88+
89+
// $.fn.smoothScroll only: whether to prevent the default click action
90+
preventDefault: true
8891

8992
}</code></pre>
9093
<p>The options object for <code>$.fn.smoothScroll</code> can take two additional properties:

jquery.smooth-scroll.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*!
2-
* Smooth Scroll - v1.4.10 - 2013-03-02
2+
* Smooth Scroll - v1.4.11 - 2013-07-15
33
* https://github.com/kswedberg/jquery-smooth-scroll
44
* Copyright (c) 2013 Karl Swedberg
55
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
66
*/
77

88
(function($) {
99

10-
var version = '1.4.10',
10+
var version = '1.4.11',
1111
defaults = {
1212
exclude: [],
1313
excludeWithin:[],
@@ -34,7 +34,10 @@ var version = '1.4.10',
3434
speed: 400,
3535

3636
// coefficient for "auto" speed
37-
autoCoefficent: 2
37+
autoCoefficent: 2,
38+
39+
// $.fn.smoothScroll only: whether to prevent the default click action
40+
preventDefault: true
3841
},
3942

4043
getScrollable = function(opts) {
@@ -126,7 +129,10 @@ $.fn.extend({
126129
}
127130

128131
if ( include ) {
129-
event.preventDefault();
132+
133+
if ( opts.preventDefault ) {
134+
event.preventDefault();
135+
}
130136

131137
$.extend( clickOpts, opts, {
132138
scrollTarget: opts.scrollTarget || thisHash,

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "smooth-scroll",
3-
"version": "1.4.10",
3+
"version": "1.4.11",
44
"scripts": {
55
"test": "./node_modules/.bin/grunt"
66
},
@@ -13,5 +13,6 @@
1313
"grunt-shell": "~0.2",
1414
"grunt-version": "~0.1.1",
1515
"grunt-contrib-watch": "~0.3.1"
16-
}
16+
},
17+
"readmeFilename": "readme.md"
1718
}

readme.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ The following options, shown with their default values, are available for both `
4040
speed: 400,
4141

4242
// coefficient for "auto" speed
43-
autoCoefficent: 2
43+
autoCoefficent: 2,
44+
45+
// $.fn.smoothScroll only: whether to prevent the default click action
46+
preventDefault: true
4447

4548
}
4649
```

smooth-scroll.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "smooth-scroll",
3-
"version": "1.4.10",
3+
"version": "1.4.11",
44
"title": "Smooth Scroll",
55
"description": "Easy implementation of smooth scrolling for same-page links",
66
"author": {

src/jquery.smooth-scroll.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function($) {
22

3-
var version = '1.4.10',
3+
var version = '1.4.11',
44
defaults = {
55
exclude: [],
66
excludeWithin:[],
@@ -27,7 +27,10 @@ var version = '1.4.10',
2727
speed: 400,
2828

2929
// coefficient for "auto" speed
30-
autoCoefficent: 2
30+
autoCoefficent: 2,
31+
32+
// $.fn.smoothScroll only: whether to prevent the default click action
33+
preventDefault: true
3134
},
3235

3336
getScrollable = function(opts) {
@@ -119,7 +122,10 @@ $.fn.extend({
119122
}
120123

121124
if ( include ) {
122-
event.preventDefault();
125+
126+
if ( opts.preventDefault ) {
127+
event.preventDefault();
128+
}
123129

124130
$.extend( clickOpts, opts, {
125131
scrollTarget: opts.scrollTarget || thisHash,

0 commit comments

Comments
 (0)