Skip to content

Commit

Permalink
Update docs and minor bump
Browse files Browse the repository at this point in the history
  • Loading branch information
kswedberg committed Dec 22, 2015
1 parent 9f34a80 commit dfe6c9e
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 31 deletions.
4 changes: 1 addition & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ module.exports = function(grunt) {
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
'<%= "\\n" %>' +
' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>' +
' (<%= _.pluck(pkg.licenses, "url").join(", ") %>)' +
' * Licensed <%= pkg.license %>' +
'<%= "\\n" %>' + ' */' +
'<%= "\\n\\n" %>'
},
Expand Down Expand Up @@ -97,7 +96,6 @@ module.exports = function(grunt) {
patch: {
src: [
'package.json',
'<%= pluginName %>.jquery.json',
'src/jquery.<%= pluginName %>.js',
'jquery.<%= pluginName %>.js'
],
Expand Down
7 changes: 6 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<meta charset="utf-8">
<title>Smooth Scroll jQuery Plugin Demo</title>
<style type="text/css">
body {
font-family: Helvetica, Arial, sans-serif;
}
.container {
margin: 40px auto;
width: 200px;
Expand All @@ -30,7 +33,9 @@
<script>
$(document).ready(function() {

$('ul.mainnav a').smoothScroll();
$('body').smoothScroll({
delegateSelector: 'ul.mainnav a'
});

$('p.subnav a').click(function(event) {
event.preventDefault();
Expand Down
11 changes: 4 additions & 7 deletions index.html

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions jquery.smooth-scroll.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*!
* jQuery Smooth Scroll - v1.5.7 - 2015-12-16
* jQuery Smooth Scroll - v1.6.0 - 2015-12-22
* https://github.com/kswedberg/jquery-smooth-scroll
* Copyright (c) 2015 Karl Swedberg
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
* Licensed MIT
*/

(function (factory) {
Expand All @@ -18,16 +18,20 @@
}
}(function ($) {

var version = '1.5.7',
var version = '1.6.0',
optionOverrides = {},
defaults = {
exclude: [],
excludeWithin:[],
excludeWithin: [],
offset: 0,

// one of 'top' or 'left'
direction: 'top',

// if set, bind click events through delegation
// supported since jQuery 1.4.2
delegateSelector: null,

// jQuery set of elements you wish to scroll (for $.smoothScroll).
// if null (default), $('html, body').firstScrollable() is used.
scrollElement: null,
Expand Down Expand Up @@ -132,9 +136,7 @@
var opts = $.extend({}, $.fn.smoothScroll.defaults, options),
locationPath = $.smoothScroll.filterPath(location.pathname);

this
.unbind('click.smoothscroll')
.bind('click.smoothscroll', function(event) {
var clickHandler = function(event) {
var link = this,
$link = $(this),
thisOpts = $.extend({}, opts, $link.data('ssOpts') || {}),
Expand Down Expand Up @@ -175,7 +177,17 @@

$.smoothScroll( clickOpts );
}
});
};

if (options.delegateSelector !== null) {
this
.undelegate(options.delegateSelector, 'click.smoothscroll')
.delegate(options.delegateSelector, 'click.smoothscroll', clickHandler);
} else {
this
.unbind('click.smoothscroll')
.bind('click.smoothscroll', clickHandler);
}

return this;
}
Expand Down
6 changes: 3 additions & 3 deletions jquery.smooth-scroll.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery-smooth-scroll",
"title": "jQuery Smooth Scroll",
"version": "1.5.7",
"version": "1.6.0",
"scripts": {},
"main": "jquery.smooth-scroll.js",
"author": {
Expand All @@ -17,14 +17,9 @@
"docs": "https://github.com/kswedberg/jquery-smooth-scroll",
"bugs": "https://github.com/kswedberg/jquery-smooth-scroll/issues",
"demo": "http://plugins.learningjquery.com/smooth-scroll/demo/",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT"
}
],
"license": "MIT",
"dependencies": {
"jquery": ">=1.3"
"jquery": ">=1.4.2"
},
"devDependencies": {
"grunt": "~0.4.0",
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ The following options, shown with their default values, are available for both `
// only use if you want to override default behavior
scrollTarget: null,

// string to use as selector for event delegation (Requires jQuery >=1.4.2)
delegateSelector: null,

// fn(opts) function to be called before scrolling occurs.
// `this` is the element(s) being scrolled
beforeScroll: function() {},
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.smooth-scroll.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function($) {
var version = '1.5.7',
var version = '1.6.0',
optionOverrides = {},
defaults = {
exclude: [],
Expand Down

0 comments on commit dfe6c9e

Please sign in to comment.