Skip to content

Commit dfe6c9e

Browse files
committed
Update docs and minor bump
1 parent 9f34a80 commit dfe6c9e

File tree

8 files changed

+41
-31
lines changed

8 files changed

+41
-31
lines changed

Gruntfile.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ module.exports = function(grunt) {
2626
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
2727
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
2828
'<%= "\\n" %>' +
29-
' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>' +
30-
' (<%= _.pluck(pkg.licenses, "url").join(", ") %>)' +
29+
' * Licensed <%= pkg.license %>' +
3130
'<%= "\\n" %>' + ' */' +
3231
'<%= "\\n\\n" %>'
3332
},
@@ -97,7 +96,6 @@ module.exports = function(grunt) {
9796
patch: {
9897
src: [
9998
'package.json',
100-
'<%= pluginName %>.jquery.json',
10199
'src/jquery.<%= pluginName %>.js',
102100
'jquery.<%= pluginName %>.js'
103101
],

demo/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<meta charset="utf-8">
55
<title>Smooth Scroll jQuery Plugin Demo</title>
66
<style type="text/css">
7+
body {
8+
font-family: Helvetica, Arial, sans-serif;
9+
}
710
.container {
811
margin: 40px auto;
912
width: 200px;
@@ -30,7 +33,9 @@
3033
<script>
3134
$(document).ready(function() {
3235

33-
$('ul.mainnav a').smoothScroll();
36+
$('body').smoothScroll({
37+
delegateSelector: 'ul.mainnav a'
38+
});
3439

3540
$('p.subnav a').click(function(event) {
3641
event.preventDefault();

index.html

Lines changed: 4 additions & 7 deletions
Large diffs are not rendered by default.

jquery.smooth-scroll.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*!
2-
* jQuery Smooth Scroll - v1.5.7 - 2015-12-16
2+
* jQuery Smooth Scroll - v1.6.0 - 2015-12-22
33
* https://github.com/kswedberg/jquery-smooth-scroll
44
* Copyright (c) 2015 Karl Swedberg
5-
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
5+
* Licensed MIT
66
*/
77

88
(function (factory) {
@@ -18,16 +18,20 @@
1818
}
1919
}(function ($) {
2020

21-
var version = '1.5.7',
21+
var version = '1.6.0',
2222
optionOverrides = {},
2323
defaults = {
2424
exclude: [],
25-
excludeWithin:[],
25+
excludeWithin: [],
2626
offset: 0,
2727

2828
// one of 'top' or 'left'
2929
direction: 'top',
3030

31+
// if set, bind click events through delegation
32+
// supported since jQuery 1.4.2
33+
delegateSelector: null,
34+
3135
// jQuery set of elements you wish to scroll (for $.smoothScroll).
3236
// if null (default), $('html, body').firstScrollable() is used.
3337
scrollElement: null,
@@ -132,9 +136,7 @@
132136
var opts = $.extend({}, $.fn.smoothScroll.defaults, options),
133137
locationPath = $.smoothScroll.filterPath(location.pathname);
134138

135-
this
136-
.unbind('click.smoothscroll')
137-
.bind('click.smoothscroll', function(event) {
139+
var clickHandler = function(event) {
138140
var link = this,
139141
$link = $(this),
140142
thisOpts = $.extend({}, opts, $link.data('ssOpts') || {}),
@@ -175,7 +177,17 @@
175177

176178
$.smoothScroll( clickOpts );
177179
}
178-
});
180+
};
181+
182+
if (options.delegateSelector !== null) {
183+
this
184+
.undelegate(options.delegateSelector, 'click.smoothscroll')
185+
.delegate(options.delegateSelector, 'click.smoothscroll', clickHandler);
186+
} else {
187+
this
188+
.unbind('click.smoothscroll')
189+
.bind('click.smoothscroll', clickHandler);
190+
}
179191

180192
return this;
181193
}

jquery.smooth-scroll.min.js

Lines changed: 3 additions & 3 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 & 8 deletions
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.5.7",
4+
"version": "1.6.0",
55
"scripts": {},
66
"main": "jquery.smooth-scroll.js",
77
"author": {
@@ -17,14 +17,9 @@
1717
"docs": "https://github.com/kswedberg/jquery-smooth-scroll",
1818
"bugs": "https://github.com/kswedberg/jquery-smooth-scroll/issues",
1919
"demo": "http://plugins.learningjquery.com/smooth-scroll/demo/",
20-
"licenses": [
21-
{
22-
"type": "MIT",
23-
"url": "https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT"
24-
}
25-
],
20+
"license": "MIT",
2621
"dependencies": {
27-
"jquery": ">=1.3"
22+
"jquery": ">=1.4.2"
2823
},
2924
"devDependencies": {
3025
"grunt": "~0.4.0",

readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ The following options, shown with their default values, are available for both `
4949
// only use if you want to override default behavior
5050
scrollTarget: null,
5151

52+
// string to use as selector for event delegation (Requires jQuery >=1.4.2)
53+
delegateSelector: null,
54+
5255
// fn(opts) function to be called before scrolling occurs.
5356
// `this` is the element(s) being scrolled
5457
beforeScroll: function() {},

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.5.7',
2+
var version = '1.6.0',
33
optionOverrides = {},
44
defaults = {
55
exclude: [],

0 commit comments

Comments
 (0)