From 26824265d4635ea1f6902b7ecd436d854b066efc Mon Sep 17 00:00:00 2001
From: Karl Swedberg
Date: Mon, 11 Aug 2014 10:06:44 -0400
Subject: [PATCH 01/82] Update bower.json, package.json
---
.npmignore | 5 +++++
Gruntfile.js | 2 +-
bower.json | 6 ++++--
package.json | 5 +++--
4 files changed, 13 insertions(+), 5 deletions(-)
create mode 100644 .npmignore
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..18d3e4e
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,5 @@
+demo
+node_modules
+lib
+bower.json
+smooth-scroll.jquery.json
diff --git a/Gruntfile.js b/Gruntfile.js
index 08b18d3..8a74afc 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -171,7 +171,7 @@ module.exports = function(grunt) {
json.name = 'jquery.' + json.name;
grunt.file.write( comp, JSON.stringify(json, null, 2) );
- grunt.log.writeln( "File '" + comp + "' updated." );
+ grunt.log.writeln( 'File "' + comp + '" updated."' );
});
grunt.registerTask('docs', 'Convert readme.md to html and concat with header and footer for index.html', function() {
diff --git a/bower.json b/bower.json
index ab25067..c9201ad 100644
--- a/bower.json
+++ b/bower.json
@@ -9,6 +9,8 @@
"demo/",
"lib/",
"src/",
- "*.json"
+ "Gruntfile.js",
+ "package.json",
+ "smooth-scroll.jquery.json"
]
-}
\ No newline at end of file
+}
diff --git a/package.json b/package.json
index c0aafbf..a1cd4f5 100644
--- a/package.json
+++ b/package.json
@@ -7,12 +7,13 @@
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.0",
+ "grunt-contrib-concat": "~0.1.2",
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-uglify": "~0.1.1",
- "grunt-contrib-concat": "~0.1.2",
+ "grunt-contrib-watch": "~0.3.1",
"grunt-shell": "~0.2",
"grunt-version": "~0.1.1",
- "grunt-contrib-watch": "~0.3.1",
+ "marked": "^0.3.2",
"node-syntaxhighlighter": "~0.8.1"
},
"readmeFilename": "readme.md"
From 34cd1729c117682b118333f313e4c002032fe058 Mon Sep 17 00:00:00 2001
From: tu-vu-duy
Date: Mon, 11 Aug 2014 11:40:38 -0400
Subject: [PATCH 02/82] Fix value of 'speed' when set default is 'auto'. Closes
#33
---
src/jquery.smooth-scroll.js | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/jquery.smooth-scroll.js b/src/jquery.smooth-scroll.js
index 9229292..2f889fe 100644
--- a/src/jquery.smooth-scroll.js
+++ b/src/jquery.smooth-scroll.js
@@ -158,7 +158,7 @@ $.smoothScroll = function(options, px) {
if ( options === 'options' && typeof px === 'object' ) {
return $.extend(optionOverrides, px);
}
- var opts, $scroller, scrollTargetOffset, speed,
+ var opts, $scroller, scrollTargetOffset, speed, delta,
scrollerOffset = 0,
offPos = 'offset',
scrollDir = 'scrollTop',
@@ -205,11 +205,15 @@ $.smoothScroll = function(options, px) {
// automatically calculate the speed of the scroll based on distance / coefficient
if (speed === 'auto') {
- // if aniProps[scrollDir] == 0 then we'll use scrollTop() value instead
- speed = aniProps[scrollDir] || $scroller.scrollTop();
+ // $scroller.scrollTop() is position before scroll, aniProps[scrollDir] is position after
+ // When delta is greater, speed will be greater.
+ delta = aniProps[scrollDir] - $scroller.scrollTop();
+ if(delta < 0) {
+ delta *= -1;
+ }
- // divide the speed by the coefficient
- speed = speed / opts.autoCoefficent;
+ // Divide the delta by the coefficient
+ speed = delta / opts.autoCoefficent;
}
aniOpts = {
From d2b1604125dc55ef75d2f9380079313768b41e20 Mon Sep 17 00:00:00 2001
From: Karl Swedberg
Date: Mon, 11 Aug 2014 11:55:20 -0400
Subject: [PATCH 03/82] Make jshint stricter and cleanup lint warnings
---
Gruntfile.js | 5 +++--
src/jquery.smooth-scroll.js | 16 +++++++---------
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index 8a74afc..ab2fc32 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -82,8 +82,9 @@ module.exports = function(grunt) {
all: ['Gruntfile.js', 'src/**/*.js'],
options: {
curly: true,
- // eqeqeq: true,
- // immed: true,
+ eqeqeq: true,
+ unused: true,
+ immed: true,
latedef: true,
newcap: true,
noarg: true,
diff --git a/src/jquery.smooth-scroll.js b/src/jquery.smooth-scroll.js
index 2f889fe..606f953 100644
--- a/src/jquery.smooth-scroll.js
+++ b/src/jquery.smooth-scroll.js
@@ -36,11 +36,11 @@ var version = '1.4.13',
getScrollable = function(opts) {
var scrollable = [],
scrolled = false,
- dir = opts.dir && opts.dir == 'left' ? 'scrollLeft' : 'scrollTop';
+ dir = opts.dir && opts.dir === 'left' ? 'scrollLeft' : 'scrollTop';
this.each(function() {
- if (this == document || this == window) { return; }
+ if (this === document || this === window) { return; }
var el = $(this);
if ( el[dir]() > 0 ) {
scrollable.push(this);
@@ -61,7 +61,7 @@ var version = '1.4.13',
// (doing this because Safari sets scrollTop async,
// so can't set it to 1 and immediately get the value.)
if (!scrollable.length) {
- this.each(function(index) {
+ this.each(function() {
if (this.nodeName === 'BODY') {
scrollable = [this];
}
@@ -74,8 +74,7 @@ var version = '1.4.13',
}
return scrollable;
- },
- isTouch = 'ontouchend' in document;
+ };
$.fn.extend({
scrollable: function(dir) {
@@ -163,8 +162,7 @@ $.smoothScroll = function(options, px) {
offPos = 'offset',
scrollDir = 'scrollTop',
aniProps = {},
- aniOpts = {},
- scrollprops = [];
+ aniOpts = {};
if (typeof options === 'number') {
opts = $.extend({link: null}, $.fn.smoothScroll.defaults, optionOverrides);
@@ -173,13 +171,13 @@ $.smoothScroll = function(options, px) {
opts = $.extend({link: null}, $.fn.smoothScroll.defaults, options || {}, optionOverrides);
if (opts.scrollElement) {
offPos = 'position';
- if (opts.scrollElement.css('position') == 'static') {
+ if (opts.scrollElement.css('position') === 'static') {
opts.scrollElement.css('position', 'relative');
}
}
}
- scrollDir = opts.direction == 'left' ? 'scrollLeft' : scrollDir;
+ scrollDir = opts.direction === 'left' ? 'scrollLeft' : scrollDir;
if ( opts.scrollElement ) {
$scroller = opts.scrollElement;
From 252e4a5726ee54d416cbc3681a508b585d9ba5e9 Mon Sep 17 00:00:00 2001
From: Karl Swedberg
Date: Mon, 11 Aug 2014 11:57:47 -0400
Subject: [PATCH 04/82] Fix misspelling of autoCoefficient
---
readme.md | 9 +++++++--
src/jquery.smooth-scroll.js | 4 ++--
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/readme.md b/readme.md
index 0e73f71..d92c7f9 100644
--- a/readme.md
+++ b/readme.md
@@ -37,10 +37,15 @@ The following options, shown with their default values, are available for both `
// `this` is the triggering element
afterScroll: function() {},
easing: 'swing',
+
+ // speed can be a number or 'auto'
+ // if 'auto', the speed will be calculated based on the formula:
+ // (current scroll position - target scroll position) / autoCoeffic
speed: 400,
- // coefficient for "auto" speed
- autoCoefficent: 2,
+ // autoCoefficent: Only used when speed set to "auto".
+ // The higher this number, the faster the scroll speed
+ autoCoefficient: 2,
// $.fn.smoothScroll only: whether to prevent the default click action
preventDefault: true
diff --git a/src/jquery.smooth-scroll.js b/src/jquery.smooth-scroll.js
index 606f953..f0e9b44 100644
--- a/src/jquery.smooth-scroll.js
+++ b/src/jquery.smooth-scroll.js
@@ -27,7 +27,7 @@ var version = '1.4.13',
speed: 400,
// coefficient for "auto" speed
- autoCoefficent: 2,
+ autoCoefficient: 2,
// $.fn.smoothScroll only: whether to prevent the default click action
preventDefault: true
@@ -211,7 +211,7 @@ $.smoothScroll = function(options, px) {
}
// Divide the delta by the coefficient
- speed = delta / opts.autoCoefficent;
+ speed = delta / opts.autoCoefficient;
}
aniOpts = {
From da9dc9763f9395f300ca12d496ec2e52c5041ab4 Mon Sep 17 00:00:00 2001
From: Karl Swedberg
Date: Mon, 11 Aug 2014 12:31:51 -0400
Subject: [PATCH 05/82] Release 1.5.0
---
Gruntfile.js | 49 +++++++++++++++++++------------------
bower.json | 2 +-
jquery.smooth-scroll.js | 40 ++++++++++++++++--------------
jquery.smooth-scroll.min.js | 6 ++---
package.json | 33 ++++++++++++++++++++++---
smooth-scroll.jquery.json | 8 ++++--
src/jquery.smooth-scroll.js | 2 +-
7 files changed, 88 insertions(+), 52 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index ab2fc32..474f787 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -2,8 +2,6 @@
module.exports = function(grunt) {
- // Because I'm lazy
- var _ = grunt.util._;
var marked = require('marked');
// var hl = require('highlight').Highlight;
var hl = require('node-syntaxhighlighter');
@@ -20,7 +18,7 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
bower: './bower.json',
- pkg: grunt.file.readJSON('smooth-scroll.jquery.json'),
+ pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/*!<%= "\\n" %>' +
' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
@@ -150,29 +148,32 @@ module.exports = function(grunt) {
grunt.registerTask( 'deploy', ['setshell:rsync', 'shell:rsync']);
- grunt.registerTask( 'bower', 'Update bower.json', function() {
- var comp = grunt.config('bower'),
- pkgName = grunt.config('pkg').name,
- pkg = grunt.file.readJSON(pkgName + '.jquery.json'),
- json = {};
-
- ['name', 'version', 'dependencies'].forEach(function(el) {
- json[el] = pkg[el];
+ grunt.registerTask( 'configs', 'Update json configs based on package.json', function() {
+ var rjQuery = /^jquery\./,
+ bowerFile = grunt.config('bower'),
+ bower = grunt.file.readJSON(bowerFile),
+ pkg = grunt.config('pkg'),
+ jqConfigFile = pkg.name.replace(rjQuery, '') + '.jquery.json',
+ jqConfig = grunt.file.readJSON(jqConfigFile);
+
+ ['name', 'main', 'version', 'dependencies', 'keywords'].forEach(function(el) {
+ bower[el] = pkg[el];
+ jqConfig[el] = pkg[el];
});
- _.extend(json, {
- main: grunt.config('concat.all.dest'),
- ignore: [
- 'demo/',
- 'lib/',
- 'src/',
- '*.json'
- ]
+
+ ['author', 'repository', 'homepage', 'docs', 'bugs', 'demo', 'licenses'].forEach(function(el) {
+ jqConfig[el] = pkg[el];
});
- json.name = 'jquery.' + json.name;
- grunt.file.write( comp, JSON.stringify(json, null, 2) );
- grunt.log.writeln( 'File "' + comp + '" updated."' );
+ jqConfig.keywords.shift();
+ jqConfig.name = jqConfig.name.replace(rjQuery, '');
+
+ grunt.file.write( bowerFile, JSON.stringify(bower, null, 2) + '\n');
+ grunt.log.writeln( 'File "' + bowerFile + '" updated."' );
+
+ grunt.file.write( jqConfigFile, JSON.stringify(jqConfig, null, 2) + '\n');
+ grunt.log.writeln( 'File "' + jqConfigFile + '" updated."' );
});
grunt.registerTask('docs', 'Convert readme.md to html and concat with header and footer for index.html', function() {
@@ -185,8 +186,8 @@ module.exports = function(grunt) {
grunt.file.write('index.html', head + doc + foot);
});
- grunt.registerTask('build', ['jshint', 'concat', 'version:same', 'bower', 'uglify', 'docs']);
- grunt.registerTask('patch', ['jshint', 'concat', 'version:bannerPatch', 'version:patch', 'bower', 'uglify']);
+ grunt.registerTask('build', ['jshint', 'concat', 'version:same', 'configs', 'uglify', 'docs']);
+ grunt.registerTask('patch', ['jshint', 'concat', 'version:bannerPatch', 'version:patch', 'configs', 'uglify']);
grunt.registerTask('default', ['build']);
grunt.loadNpmTasks('grunt-contrib-jshint');
diff --git a/bower.json b/bower.json
index c9201ad..712f762 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "jquery.smooth-scroll",
- "version": "1.4.13",
+ "version": "1.5.0",
"dependencies": {
"jquery": ">=1.3"
},
diff --git a/jquery.smooth-scroll.js b/jquery.smooth-scroll.js
index 7d527c3..d7f3ca6 100644
--- a/jquery.smooth-scroll.js
+++ b/jquery.smooth-scroll.js
@@ -1,12 +1,12 @@
/*!
- * Smooth Scroll - v1.4.13 - 2013-11-02
+ * Smooth Scroll - v1.5.0 - 2014-08-11
* https://github.com/kswedberg/jquery-smooth-scroll
- * Copyright (c) 2013 Karl Swedberg
+ * Copyright (c) 2014 Karl Swedberg
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
*/
(function($) {
-var version = '1.4.13',
+var version = '1.5.0',
optionOverrides = {},
defaults = {
exclude: [],
@@ -34,7 +34,7 @@ var version = '1.4.13',
speed: 400,
// coefficient for "auto" speed
- autoCoefficent: 2,
+ autoCoefficient: 2,
// $.fn.smoothScroll only: whether to prevent the default click action
preventDefault: true
@@ -43,11 +43,11 @@ var version = '1.4.13',
getScrollable = function(opts) {
var scrollable = [],
scrolled = false,
- dir = opts.dir && opts.dir == 'left' ? 'scrollLeft' : 'scrollTop';
+ dir = opts.dir && opts.dir === 'left' ? 'scrollLeft' : 'scrollTop';
this.each(function() {
- if (this == document || this == window) { return; }
+ if (this === document || this === window) { return; }
var el = $(this);
if ( el[dir]() > 0 ) {
scrollable.push(this);
@@ -68,7 +68,7 @@ var version = '1.4.13',
// (doing this because Safari sets scrollTop async,
// so can't set it to 1 and immediately get the value.)
if (!scrollable.length) {
- this.each(function(index) {
+ this.each(function() {
if (this.nodeName === 'BODY') {
scrollable = [this];
}
@@ -81,8 +81,7 @@ var version = '1.4.13',
}
return scrollable;
- },
- isTouch = 'ontouchend' in document;
+ };
$.fn.extend({
scrollable: function(dir) {
@@ -152,6 +151,7 @@ $.fn.extend({
scrollTarget: thisOpts.scrollTarget || thisHash,
link: link
});
+
$.smoothScroll( clickOpts );
}
});
@@ -164,13 +164,12 @@ $.smoothScroll = function(options, px) {
if ( options === 'options' && typeof px === 'object' ) {
return $.extend(optionOverrides, px);
}
- var opts, $scroller, scrollTargetOffset, speed,
+ var opts, $scroller, scrollTargetOffset, speed, delta,
scrollerOffset = 0,
offPos = 'offset',
scrollDir = 'scrollTop',
aniProps = {},
- aniOpts = {},
- scrollprops = [];
+ aniOpts = {};
if (typeof options === 'number') {
opts = $.extend({link: null}, $.fn.smoothScroll.defaults, optionOverrides);
@@ -179,13 +178,13 @@ $.smoothScroll = function(options, px) {
opts = $.extend({link: null}, $.fn.smoothScroll.defaults, options || {}, optionOverrides);
if (opts.scrollElement) {
offPos = 'position';
- if (opts.scrollElement.css('position') == 'static') {
+ if (opts.scrollElement.css('position') === 'static') {
opts.scrollElement.css('position', 'relative');
}
}
}
- scrollDir = opts.direction == 'left' ? 'scrollLeft' : scrollDir;
+ scrollDir = opts.direction === 'left' ? 'scrollLeft' : scrollDir;
if ( opts.scrollElement ) {
$scroller = opts.scrollElement;
@@ -211,11 +210,15 @@ $.smoothScroll = function(options, px) {
// automatically calculate the speed of the scroll based on distance / coefficient
if (speed === 'auto') {
- // if aniProps[scrollDir] == 0 then we'll use scrollTop() value instead
- speed = aniProps[scrollDir] || $scroller.scrollTop();
+ // $scroller.scrollTop() is position before scroll, aniProps[scrollDir] is position after
+ // When delta is greater, speed will be greater.
+ delta = aniProps[scrollDir] - $scroller.scrollTop();
+ if(delta < 0) {
+ delta *= -1;
+ }
- // divide the speed by the coefficient
- speed = speed / opts.autoCoefficent;
+ // Divide the delta by the coefficient
+ speed = delta / opts.autoCoefficient;
}
aniOpts = {
@@ -239,6 +242,7 @@ $.smoothScroll = function(options, px) {
$.smoothScroll.version = version;
$.smoothScroll.filterPath = function(string) {
+ string = string || '';
return string
.replace(/^\//,'')
.replace(/(?:index|default).[a-zA-Z]{3,4}$/,'')
diff --git a/jquery.smooth-scroll.min.js b/jquery.smooth-scroll.min.js
index e0cf64a..f5cb598 100644
--- a/jquery.smooth-scroll.min.js
+++ b/jquery.smooth-scroll.min.js
@@ -1,7 +1,7 @@
/*!
- * Smooth Scroll - v1.4.13 - 2013-11-02
+ * Smooth Scroll - v1.5.0 - 2014-08-11
* https://github.com/kswedberg/jquery-smooth-scroll
- * Copyright (c) 2013 Karl Swedberg
+ * Copyright (c) 2014 Karl Swedberg
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
*/
-(function(t){function e(t){return t.replace(/(:|\.)/g,"\\$1")}var l="1.4.13",o={},s={exclude:[],excludeWithin:[],offset:0,direction:"top",scrollElement:null,scrollTarget:null,beforeScroll:function(){},afterScroll:function(){},easing:"swing",speed:400,autoCoefficent:2,preventDefault:!0},n=function(e){var l=[],o=!1,s=e.dir&&"left"==e.dir?"scrollLeft":"scrollTop";return this.each(function(){if(this!=document&&this!=window){var e=t(this);e[s]()>0?l.push(this):(e[s](1),o=e[s]()>0,o&&l.push(this),e[s](0))}}),l.length||this.each(function(){"BODY"===this.nodeName&&(l=[this])}),"first"===e.el&&l.length>1&&(l=[l[0]]),l};t.fn.extend({scrollable:function(t){var e=n.call(this,{dir:t});return this.pushStack(e)},firstScrollable:function(t){var e=n.call(this,{el:"first",dir:t});return this.pushStack(e)},smoothScroll:function(l,o){if(l=l||{},"options"===l)return o?this.each(function(){var e=t(this),l=t.extend(e.data("ssOpts")||{},o);t(this).data("ssOpts",l)}):this.first().data("ssOpts");var s=t.extend({},t.fn.smoothScroll.defaults,l),n=t.smoothScroll.filterPath(location.pathname);return this.unbind("click.smoothscroll").bind("click.smoothscroll",function(l){var o=this,r=t(this),i=t.extend({},s,r.data("ssOpts")||{}),c=s.exclude,a=i.excludeWithin,f=0,h=0,u=!0,d={},p=location.hostname===o.hostname||!o.hostname,m=i.scrollTarget||(t.smoothScroll.filterPath(o.pathname)||n)===n,S=e(o.hash);if(i.scrollTarget||p&&m&&S){for(;u&&c.length>f;)r.is(e(c[f++]))&&(u=!1);for(;u&&a.length>h;)r.closest(a[h++]).length&&(u=!1)}else u=!1;u&&(i.preventDefault&&l.preventDefault(),t.extend(d,i,{scrollTarget:i.scrollTarget||S,link:o}),t.smoothScroll(d))}),this}}),t.smoothScroll=function(e,l){if("options"===e&&"object"==typeof l)return t.extend(o,l);var s,n,r,i,c=0,a="offset",f="scrollTop",h={},u={};"number"==typeof e?(s=t.extend({link:null},t.fn.smoothScroll.defaults,o),r=e):(s=t.extend({link:null},t.fn.smoothScroll.defaults,e||{},o),s.scrollElement&&(a="position","static"==s.scrollElement.css("position")&&s.scrollElement.css("position","relative"))),f="left"==s.direction?"scrollLeft":f,s.scrollElement?(n=s.scrollElement,/^(?:HTML|BODY)$/.test(n[0].nodeName)||(c=n[f]())):n=t("html, body").firstScrollable(s.direction),s.beforeScroll.call(n,s),r="number"==typeof e?e:l||t(s.scrollTarget)[a]()&&t(s.scrollTarget)[a]()[s.direction]||0,h[f]=r+c+s.offset,i=s.speed,"auto"===i&&(i=h[f]||n.scrollTop(),i/=s.autoCoefficent),u={duration:i,easing:s.easing,complete:function(){s.afterScroll.call(s.link,s)}},s.step&&(u.step=s.step),n.length?n.stop().animate(h,u):s.afterScroll.call(s.link,s)},t.smoothScroll.version=l,t.smoothScroll.filterPath=function(t){return t.replace(/^\//,"").replace(/(?:index|default).[a-zA-Z]{3,4}$/,"").replace(/\/$/,"")},t.fn.smoothScroll.defaults=s})(jQuery);
\ No newline at end of file
+(function(t){function e(t){return t.replace(/(:|\.)/g,"\\$1")}var l="1.5.0",o={},s={exclude:[],excludeWithin:[],offset:0,direction:"top",scrollElement:null,scrollTarget:null,beforeScroll:function(){},afterScroll:function(){},easing:"swing",speed:400,autoCoefficient:2,preventDefault:!0},n=function(e){var l=[],o=!1,s=e.dir&&"left"===e.dir?"scrollLeft":"scrollTop";return this.each(function(){if(this!==document&&this!==window){var e=t(this);e[s]()>0?l.push(this):(e[s](1),o=e[s]()>0,o&&l.push(this),e[s](0))}}),l.length||this.each(function(){"BODY"===this.nodeName&&(l=[this])}),"first"===e.el&&l.length>1&&(l=[l[0]]),l};t.fn.extend({scrollable:function(t){var e=n.call(this,{dir:t});return this.pushStack(e)},firstScrollable:function(t){var e=n.call(this,{el:"first",dir:t});return this.pushStack(e)},smoothScroll:function(l,o){if(l=l||{},"options"===l)return o?this.each(function(){var e=t(this),l=t.extend(e.data("ssOpts")||{},o);t(this).data("ssOpts",l)}):this.first().data("ssOpts");var s=t.extend({},t.fn.smoothScroll.defaults,l),n=t.smoothScroll.filterPath(location.pathname);return this.unbind("click.smoothscroll").bind("click.smoothscroll",function(l){var o=this,r=t(this),i=t.extend({},s,r.data("ssOpts")||{}),c=s.exclude,a=i.excludeWithin,f=0,h=0,u=!0,d={},p=location.hostname===o.hostname||!o.hostname,m=i.scrollTarget||(t.smoothScroll.filterPath(o.pathname)||n)===n,S=e(o.hash);if(i.scrollTarget||p&&m&&S){for(;u&&c.length>f;)r.is(e(c[f++]))&&(u=!1);for(;u&&a.length>h;)r.closest(a[h++]).length&&(u=!1)}else u=!1;u&&(i.preventDefault&&l.preventDefault(),t.extend(d,i,{scrollTarget:i.scrollTarget||S,link:o}),t.smoothScroll(d))}),this}}),t.smoothScroll=function(e,l){if("options"===e&&"object"==typeof l)return t.extend(o,l);var s,n,r,i,c,a=0,f="offset",h="scrollTop",u={},d={};"number"==typeof e?(s=t.extend({link:null},t.fn.smoothScroll.defaults,o),r=e):(s=t.extend({link:null},t.fn.smoothScroll.defaults,e||{},o),s.scrollElement&&(f="position","static"===s.scrollElement.css("position")&&s.scrollElement.css("position","relative"))),h="left"===s.direction?"scrollLeft":h,s.scrollElement?(n=s.scrollElement,/^(?:HTML|BODY)$/.test(n[0].nodeName)||(a=n[h]())):n=t("html, body").firstScrollable(s.direction),s.beforeScroll.call(n,s),r="number"==typeof e?e:l||t(s.scrollTarget)[f]()&&t(s.scrollTarget)[f]()[s.direction]||0,u[h]=r+a+s.offset,i=s.speed,"auto"===i&&(c=u[h]-n.scrollTop(),0>c&&(c*=-1),i=c/s.autoCoefficient),d={duration:i,easing:s.easing,complete:function(){s.afterScroll.call(s.link,s)}},s.step&&(d.step=s.step),n.length?n.stop().animate(u,d):s.afterScroll.call(s.link,s)},t.smoothScroll.version=l,t.smoothScroll.filterPath=function(t){return t=t||"",t.replace(/^\//,"").replace(/(?:index|default).[a-zA-Z]{3,4}$/,"").replace(/\/$/,"")},t.fn.smoothScroll.defaults=s})(jQuery);
\ No newline at end of file
diff --git a/package.json b/package.json
index a1cd4f5..ef09406 100644
--- a/package.json
+++ b/package.json
@@ -1,10 +1,32 @@
{
- "name": "smooth-scroll",
- "version": "1.4.13",
+ "name": "jquery.smooth-scroll",
+ "version": "1.5.0",
"scripts": {
"test": "./node_modules/.bin/grunt"
},
- "dependencies": {},
+ "main": "jquery.smooth-scroll.js",
+ "author": {
+ "name": "Karl Swedberg",
+ "email": "kswedberg@gmail.com",
+ "url": "http://www.learningjquery.com/"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/kswedberg/jquery-smooth-scroll"
+ },
+ "homepage": "https://github.com/kswedberg/jquery-smooth-scroll",
+ "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"
+ }
+ ],
+ "dependencies": {
+ "jquery": ">=1.3"
+ },
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-concat": "~0.1.2",
@@ -16,5 +38,10 @@
"marked": "^0.3.2",
"node-syntaxhighlighter": "~0.8.1"
},
+ "keywords": [
+ "jQuery",
+ "scroll",
+ "animation"
+ ],
"readmeFilename": "readme.md"
}
diff --git a/smooth-scroll.jquery.json b/smooth-scroll.jquery.json
index 723226c..e86eb2c 100644
--- a/smooth-scroll.jquery.json
+++ b/smooth-scroll.jquery.json
@@ -1,6 +1,6 @@
{
"name": "smooth-scroll",
- "version": "1.4.13",
+ "version": "1.5.0",
"title": "Smooth Scroll",
"description": "Easy implementation of smooth scrolling for same-page links",
"author": {
@@ -25,5 +25,9 @@
"dependencies": {
"jquery": ">=1.3"
},
- "keywords": ["scroll", "animation"]
+ "keywords": [
+ "scroll",
+ "animation"
+ ],
+ "main": "jquery.smooth-scroll.js"
}
diff --git a/src/jquery.smooth-scroll.js b/src/jquery.smooth-scroll.js
index f0e9b44..3ecc729 100644
--- a/src/jquery.smooth-scroll.js
+++ b/src/jquery.smooth-scroll.js
@@ -1,5 +1,5 @@
(function($) {
-var version = '1.4.13',
+var version = '1.5.0',
optionOverrides = {},
defaults = {
exclude: [],
From f4f417970c8903a7dcf7e256cbd0afe767dd0f5a Mon Sep 17 00:00:00 2001
From: Karl Swedberg
Date: Wed, 1 Oct 2014 12:31:44 -0400
Subject: [PATCH 06/82] Avoid false positive on pathMatch when filtered
link.pathname is empty string. Fixes #64.
---
package.json | 9 ++++-----
src/jquery.smooth-scroll.js | 2 +-
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/package.json b/package.json
index ef09406..943dbe2 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,7 @@
{
- "name": "jquery.smooth-scroll",
+ "name": "smooth-scroll",
"version": "1.5.0",
- "scripts": {
- "test": "./node_modules/.bin/grunt"
- },
+ "scripts": {},
"main": "jquery.smooth-scroll.js",
"author": {
"name": "Karl Swedberg",
@@ -36,7 +34,8 @@
"grunt-shell": "~0.2",
"grunt-version": "~0.1.1",
"marked": "^0.3.2",
- "node-syntaxhighlighter": "~0.8.1"
+ "node-syntaxhighlighter": "~0.8.1",
+ "qunitjs": "^1.15.0"
},
"keywords": [
"jQuery",
diff --git a/src/jquery.smooth-scroll.js b/src/jquery.smooth-scroll.js
index 3ecc729..5847fdf 100644
--- a/src/jquery.smooth-scroll.js
+++ b/src/jquery.smooth-scroll.js
@@ -116,7 +116,7 @@ $.fn.extend({
include = true,
clickOpts = {},
hostMatch = ((location.hostname === link.hostname) || !link.hostname),
- pathMatch = thisOpts.scrollTarget || ( $.smoothScroll.filterPath(link.pathname) || locationPath ) === locationPath,
+ pathMatch = thisOpts.scrollTarget || ( $.smoothScroll.filterPath(link.pathname) === locationPath ),
thisHash = escapeSelector(link.hash);
if ( !thisOpts.scrollTarget && (!hostMatch || !pathMatch || !thisHash) ) {
From 9090e132acb1d836d3eeba4033b2d1eb4e5b5945 Mon Sep 17 00:00:00 2001
From: Karl Swedberg
Date: Wed, 1 Oct 2014 13:08:43 -0400
Subject: [PATCH 07/82] Clean up package.json and Gruntfile.js and build files
---
Gruntfile.js | 48 +++++++++++++------------------------
bower.json | 4 ++++
index.html | 32 +++++++++++++++----------
jquery.smooth-scroll.js | 4 ++--
jquery.smooth-scroll.min.js | 4 ++--
lib/tmpl/header.tpl | 2 +-
package.json | 3 ++-
7 files changed, 47 insertions(+), 50 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index 474f787..77a9fee 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -17,11 +17,12 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
+ pluginName: 'smooth-scroll',
bower: './bower.json',
pkg: grunt.file.readJSON('package.json'),
meta: {
banner: '/*!<%= "\\n" %>' +
- ' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
+ ' * <%= pkg.title %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") + "\\n" %>' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
@@ -33,8 +34,8 @@ module.exports = function(grunt) {
},
concat: {
all: {
- src: ['src/jquery.<%= pkg.name %>.js'],
- dest: 'jquery.<%= pkg.name %>.js'
+ src: ['src/jquery.<%= pluginName %>.js'],
+ dest: 'jquery.<%= pluginName %>.js'
},
options: {
stripBanners: true,
@@ -44,7 +45,7 @@ module.exports = function(grunt) {
uglify: {
all: {
files: {
- 'jquery.<%= pkg.name %>.min.js': ['<%= concat.all.dest %>']
+ 'jquery.<%= pluginName %>.min.js': ['<%= concat.all.dest %>']
},
options: {
preserveComments: 'some'
@@ -62,20 +63,6 @@ module.exports = function(grunt) {
}
},
- shell: {
- rsync: {
- // command is set by setshell:rsync.
- options: {
- stdout: true
- }
- }
- },
- setshell: {
- rsync: {
- file: 'gitignore/settings.json',
- cmdAppend: '<%= pkg.name %>/'
- }
- },
jshint: {
all: ['Gruntfile.js', 'src/**/*.js'],
options: {
@@ -100,20 +87,20 @@ module.exports = function(grunt) {
version: {
patch: {
src: [
- '<%= pkg.name %>.jquery.json',
+ '<%= pluginName %>.jquery.json',
'package.json',
- 'src/jquery.<%= pkg.name %>.js',
- 'jquery.<%= pkg.name %>.js'
+ 'src/jquery.<%= pluginName %>.js',
+ 'jquery.<%= pluginName %>.js'
],
options: {
release: 'patch'
}
},
same: {
- src: ['package.json', 'src/jquery.<%= pkg.name %>.js', 'jquery.<%= pkg.name %>.js']
+ src: ['package.json', 'src/jquery.<%= pluginName %>.js', 'jquery.<%= pluginName %>.js']
},
bannerPatch: {
- src: ['jquery.<%= pkg.name %>.js'],
+ src: ['jquery.<%= pluginName %>.js'],
options: {
prefix: '- v',
release: 'patch'
@@ -149,25 +136,25 @@ module.exports = function(grunt) {
grunt.registerTask( 'deploy', ['setshell:rsync', 'shell:rsync']);
grunt.registerTask( 'configs', 'Update json configs based on package.json', function() {
- var rjQuery = /^jquery\./,
+ var pkg = grunt.config('pkg'),
+ pkgBasename = grunt.config('pluginName'),
bowerFile = grunt.config('bower'),
bower = grunt.file.readJSON(bowerFile),
- pkg = grunt.config('pkg'),
- jqConfigFile = pkg.name.replace(rjQuery, '') + '.jquery.json',
+ jqConfigFile = pkgBasename + '.jquery.json',
jqConfig = grunt.file.readJSON(jqConfigFile);
- ['name', 'main', 'version', 'dependencies', 'keywords'].forEach(function(el) {
+ ['main', 'version', 'dependencies', 'keywords'].forEach(function(el) {
bower[el] = pkg[el];
jqConfig[el] = pkg[el];
});
-
['author', 'repository', 'homepage', 'docs', 'bugs', 'demo', 'licenses'].forEach(function(el) {
jqConfig[el] = pkg[el];
});
jqConfig.keywords.shift();
- jqConfig.name = jqConfig.name.replace(rjQuery, '');
+ jqConfig.name = pkgBasename;
+ bower.name = 'jquery.' + pkgBasename;
grunt.file.write( bowerFile, JSON.stringify(bower, null, 2) + '\n');
grunt.log.writeln( 'File "' + bowerFile + '" updated."' );
@@ -178,11 +165,10 @@ module.exports = function(grunt) {
grunt.registerTask('docs', 'Convert readme.md to html and concat with header and footer for index.html', function() {
var readme = grunt.file.read('readme.md'),
- head = grunt.template.process(grunt.file.read('lib/tmpl/header.tpl')),
+ head = grunt.template.process( grunt.file.read('lib/tmpl/header.tpl') ),
foot = grunt.file.read('lib/tmpl/footer.tpl'),
doc = marked(readme);
-
grunt.file.write('index.html', head + doc + foot);
});
diff --git a/bower.json b/bower.json
index 712f762..17bcf3b 100644
--- a/bower.json
+++ b/bower.json
@@ -12,5 +12,9 @@
"Gruntfile.js",
"package.json",
"smooth-scroll.jquery.json"
+ ],
+ "keywords": [
+ "scroll",
+ "animation"
]
}
diff --git a/index.html b/index.html
index 54aced3..e2d9e7f 100644
--- a/index.html
+++ b/index.html
@@ -72,9 +72,9 @@
-Smooth Scroll Plugin
-Features
-$.fn.smoothScroll
+
+Features
+
- Allows for easy implementation of smooth scrolling for same-page links.
- Works like this:
$('a').smoothScroll();
@@ -86,22 +86,27 @@ $.fn.smoothScroll
- Add a callback function that is triggered after the scroll is complete:
$('a').smoothScroll({afterScroll: function() { alert('we made it!'); }});
- Add back button support by including a history management plugin such as Ben Alman's BBQ. See demo/bbq.html for an example of how to implement this.
-Options
+Options
The following options, shown with their default values, are available for both $.fn.smoothScroll
and $.smoothScroll
:
-1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | {
offset: 0,
direction: 'top' ,
scrollTarget: null ,
beforeScroll: function () {},
afterScroll: function () {},
easing: 'swing' ,
speed: 400,
autoCoefficent: 2,
preventDefault: true
}
|
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | {
offset: 0,
direction: 'top' ,
scrollTarget: null ,
beforeScroll: function () {},
afterScroll: function () {},
easing: 'swing' ,
speed: 400,
autoCoefficient: 2,
preventDefault: true
}
|
+
The options object for $.fn.smoothScroll
can take two additional properties:
exclude
and excludeWithin
. The value for both of these is an array of
selectors, DOM elements or jQuery objects. Default value for both is an
empty array.
-$.smoothScroll
+Setting options after initial call
+If you need to change any of the options after you've already called .smoothScroll()
,
+you can do so by passing the "options"
string as the first argument and an
+options object as the second.
+
- Utility method works without a selector:
$.smoothScroll()
- Can be used to scroll any element (not just
document.documentElement
/
document.body
)
Doesn't automatically fire, so you need to bind it to some other user
interaction. For example:
-1 2 3 4 5 6 7 | $( 'button.scrollsomething' ).on( 'click' , function () {
$.smoothScroll({
scrollElement: $( 'div.scrollme' ),
scrollTarget: '#findme'
});
return false ;
});
|
-
+
1 2 3 4 5 6 7 | $( 'button.scrollsomething' ).on( 'click' , function () {
$.smoothScroll({
scrollElement: $( 'div.scrollme' ),
scrollTarget: '#findme'
});
return false ;
});
|
+
The $.smoothScroll
method can take one or two arguments.
- If the first argument is a number, the document is scrolled to that
@@ -111,18 +116,19 @@
$.smoothScroll
-Additional Option
+Additional Option
The following option, in addition to those listed for $.fn.smoothScroll
above, is available
for $.smoothScroll
:
-
-$.fn.scrollable
+
+
+
- Selects the matched element(s) that are scrollable. Acts just like a
DOM traversal method such as
.find()
or .next()
.
- The resulting jQuery set may consist of zero, one, or multiple
elements.
-$.fn.firstScrollable
+
- Selects the first matched element that is scrollable. Acts just like a
DOM traversal method such as
.find()
or .next()
.
@@ -132,7 +138,7 @@ $.fn.firstScrollable
$('html, body').firstScrollable().animate({scrollTop: someNumber},
someSpeed)
-Notes
+Notes
- To determine where to scroll the page, the
$.fn.smoothScroll
method looks
for an element with an id attribute that matches the <a>
element's hash.
diff --git a/jquery.smooth-scroll.js b/jquery.smooth-scroll.js
index d7f3ca6..1b7144c 100644
--- a/jquery.smooth-scroll.js
+++ b/jquery.smooth-scroll.js
@@ -1,5 +1,5 @@
/*!
- * Smooth Scroll - v1.5.0 - 2014-08-11
+ * jQuery Smooth Scroll - v1.5.0 - 2014-10-01
* https://github.com/kswedberg/jquery-smooth-scroll
* Copyright (c) 2014 Karl Swedberg
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
@@ -123,7 +123,7 @@ $.fn.extend({
include = true,
clickOpts = {},
hostMatch = ((location.hostname === link.hostname) || !link.hostname),
- pathMatch = thisOpts.scrollTarget || ( $.smoothScroll.filterPath(link.pathname) || locationPath ) === locationPath,
+ pathMatch = thisOpts.scrollTarget || ( $.smoothScroll.filterPath(link.pathname) === locationPath ),
thisHash = escapeSelector(link.hash);
if ( !thisOpts.scrollTarget && (!hostMatch || !pathMatch || !thisHash) ) {
diff --git a/jquery.smooth-scroll.min.js b/jquery.smooth-scroll.min.js
index f5cb598..7b6ac13 100644
--- a/jquery.smooth-scroll.min.js
+++ b/jquery.smooth-scroll.min.js
@@ -1,7 +1,7 @@
/*!
- * Smooth Scroll - v1.5.0 - 2014-08-11
+ * jQuery Smooth Scroll - v1.5.0 - 2014-10-01
* https://github.com/kswedberg/jquery-smooth-scroll
* Copyright (c) 2014 Karl Swedberg
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
*/
-(function(t){function e(t){return t.replace(/(:|\.)/g,"\\$1")}var l="1.5.0",o={},s={exclude:[],excludeWithin:[],offset:0,direction:"top",scrollElement:null,scrollTarget:null,beforeScroll:function(){},afterScroll:function(){},easing:"swing",speed:400,autoCoefficient:2,preventDefault:!0},n=function(e){var l=[],o=!1,s=e.dir&&"left"===e.dir?"scrollLeft":"scrollTop";return this.each(function(){if(this!==document&&this!==window){var e=t(this);e[s]()>0?l.push(this):(e[s](1),o=e[s]()>0,o&&l.push(this),e[s](0))}}),l.length||this.each(function(){"BODY"===this.nodeName&&(l=[this])}),"first"===e.el&&l.length>1&&(l=[l[0]]),l};t.fn.extend({scrollable:function(t){var e=n.call(this,{dir:t});return this.pushStack(e)},firstScrollable:function(t){var e=n.call(this,{el:"first",dir:t});return this.pushStack(e)},smoothScroll:function(l,o){if(l=l||{},"options"===l)return o?this.each(function(){var e=t(this),l=t.extend(e.data("ssOpts")||{},o);t(this).data("ssOpts",l)}):this.first().data("ssOpts");var s=t.extend({},t.fn.smoothScroll.defaults,l),n=t.smoothScroll.filterPath(location.pathname);return this.unbind("click.smoothscroll").bind("click.smoothscroll",function(l){var o=this,r=t(this),i=t.extend({},s,r.data("ssOpts")||{}),c=s.exclude,a=i.excludeWithin,f=0,h=0,u=!0,d={},p=location.hostname===o.hostname||!o.hostname,m=i.scrollTarget||(t.smoothScroll.filterPath(o.pathname)||n)===n,S=e(o.hash);if(i.scrollTarget||p&&m&&S){for(;u&&c.length>f;)r.is(e(c[f++]))&&(u=!1);for(;u&&a.length>h;)r.closest(a[h++]).length&&(u=!1)}else u=!1;u&&(i.preventDefault&&l.preventDefault(),t.extend(d,i,{scrollTarget:i.scrollTarget||S,link:o}),t.smoothScroll(d))}),this}}),t.smoothScroll=function(e,l){if("options"===e&&"object"==typeof l)return t.extend(o,l);var s,n,r,i,c,a=0,f="offset",h="scrollTop",u={},d={};"number"==typeof e?(s=t.extend({link:null},t.fn.smoothScroll.defaults,o),r=e):(s=t.extend({link:null},t.fn.smoothScroll.defaults,e||{},o),s.scrollElement&&(f="position","static"===s.scrollElement.css("position")&&s.scrollElement.css("position","relative"))),h="left"===s.direction?"scrollLeft":h,s.scrollElement?(n=s.scrollElement,/^(?:HTML|BODY)$/.test(n[0].nodeName)||(a=n[h]())):n=t("html, body").firstScrollable(s.direction),s.beforeScroll.call(n,s),r="number"==typeof e?e:l||t(s.scrollTarget)[f]()&&t(s.scrollTarget)[f]()[s.direction]||0,u[h]=r+a+s.offset,i=s.speed,"auto"===i&&(c=u[h]-n.scrollTop(),0>c&&(c*=-1),i=c/s.autoCoefficient),d={duration:i,easing:s.easing,complete:function(){s.afterScroll.call(s.link,s)}},s.step&&(d.step=s.step),n.length?n.stop().animate(u,d):s.afterScroll.call(s.link,s)},t.smoothScroll.version=l,t.smoothScroll.filterPath=function(t){return t=t||"",t.replace(/^\//,"").replace(/(?:index|default).[a-zA-Z]{3,4}$/,"").replace(/\/$/,"")},t.fn.smoothScroll.defaults=s})(jQuery);
\ No newline at end of file
+(function(t){function e(t){return t.replace(/(:|\.)/g,"\\$1")}var l="1.5.0",o={},s={exclude:[],excludeWithin:[],offset:0,direction:"top",scrollElement:null,scrollTarget:null,beforeScroll:function(){},afterScroll:function(){},easing:"swing",speed:400,autoCoefficient:2,preventDefault:!0},n=function(e){var l=[],o=!1,s=e.dir&&"left"===e.dir?"scrollLeft":"scrollTop";return this.each(function(){if(this!==document&&this!==window){var e=t(this);e[s]()>0?l.push(this):(e[s](1),o=e[s]()>0,o&&l.push(this),e[s](0))}}),l.length||this.each(function(){"BODY"===this.nodeName&&(l=[this])}),"first"===e.el&&l.length>1&&(l=[l[0]]),l};t.fn.extend({scrollable:function(t){var e=n.call(this,{dir:t});return this.pushStack(e)},firstScrollable:function(t){var e=n.call(this,{el:"first",dir:t});return this.pushStack(e)},smoothScroll:function(l,o){if(l=l||{},"options"===l)return o?this.each(function(){var e=t(this),l=t.extend(e.data("ssOpts")||{},o);t(this).data("ssOpts",l)}):this.first().data("ssOpts");var s=t.extend({},t.fn.smoothScroll.defaults,l),n=t.smoothScroll.filterPath(location.pathname);return this.unbind("click.smoothscroll").bind("click.smoothscroll",function(l){var o=this,r=t(this),i=t.extend({},s,r.data("ssOpts")||{}),c=s.exclude,a=i.excludeWithin,f=0,h=0,u=!0,d={},p=location.hostname===o.hostname||!o.hostname,m=i.scrollTarget||t.smoothScroll.filterPath(o.pathname)===n,S=e(o.hash);if(i.scrollTarget||p&&m&&S){for(;u&&c.length>f;)r.is(e(c[f++]))&&(u=!1);for(;u&&a.length>h;)r.closest(a[h++]).length&&(u=!1)}else u=!1;u&&(i.preventDefault&&l.preventDefault(),t.extend(d,i,{scrollTarget:i.scrollTarget||S,link:o}),t.smoothScroll(d))}),this}}),t.smoothScroll=function(e,l){if("options"===e&&"object"==typeof l)return t.extend(o,l);var s,n,r,i,c,a=0,f="offset",h="scrollTop",u={},d={};"number"==typeof e?(s=t.extend({link:null},t.fn.smoothScroll.defaults,o),r=e):(s=t.extend({link:null},t.fn.smoothScroll.defaults,e||{},o),s.scrollElement&&(f="position","static"===s.scrollElement.css("position")&&s.scrollElement.css("position","relative"))),h="left"===s.direction?"scrollLeft":h,s.scrollElement?(n=s.scrollElement,/^(?:HTML|BODY)$/.test(n[0].nodeName)||(a=n[h]())):n=t("html, body").firstScrollable(s.direction),s.beforeScroll.call(n,s),r="number"==typeof e?e:l||t(s.scrollTarget)[f]()&&t(s.scrollTarget)[f]()[s.direction]||0,u[h]=r+a+s.offset,i=s.speed,"auto"===i&&(c=u[h]-n.scrollTop(),0>c&&(c*=-1),i=c/s.autoCoefficient),d={duration:i,easing:s.easing,complete:function(){s.afterScroll.call(s.link,s)}},s.step&&(d.step=s.step),n.length?n.stop().animate(u,d):s.afterScroll.call(s.link,s)},t.smoothScroll.version=l,t.smoothScroll.filterPath=function(t){return t=t||"",t.replace(/^\//,"").replace(/(?:index|default).[a-zA-Z]{3,4}$/,"").replace(/\/$/,"")},t.fn.smoothScroll.defaults=s})(jQuery);
\ No newline at end of file
diff --git a/lib/tmpl/header.tpl b/lib/tmpl/header.tpl
index 316ac36..afcedae 100644
--- a/lib/tmpl/header.tpl
+++ b/lib/tmpl/header.tpl
@@ -3,7 +3,7 @@
- jQuery <%= pkg.title %> Plugin
+ <%= pkg.title %> Plugin
+
+
+
+
+
+
+
Bacon ipsum dolor amet andouille tri-tip salami frankfurter fatback venison. Cupim sausage rump boudin pork loin, salami kielbasa chuck jowl venison kevin prosciutto flank ribeye. Alcatra chuck sausage meatball beef ribs brisket biltong rump andouille tenderloin leberkas. Bacon andouille pork loin chuck shankle, ground round hamburger ham hock ball tip meatball sirloin drumstick flank kielbasa prosciutto.
+
Hamburger pig sausage, pancetta rump turducken shankle landjaeger pork belly bresaola jerky brisket leberkas porchetta swine. Pork shankle salami, sausage ham cupim andouille. Sirloin sausage jerky, leberkas chuck short ribs pancetta t-bone kielbasa strip steak prosciutto salami beef ribs frankfurter. Brisket doner andouille t-bone prosciutto short loin. Kielbasa tenderloin doner beef ribs shankle.
+
Kielbasa cupim boudin shank frankfurter. Short loin shank shankle sausage, salami pork loin leberkas biltong venison. Bresaola chuck chicken drumstick. Fatback cupim short ribs jerky brisket pancetta flank cow beef ribs salami capicola picanha rump short loin meatloaf. Corned beef meatloaf pork belly picanha alcatra pork chop.
+
Sirloin frankfurter tongue pork, filet mignon drumstick shankle beef ribs tri-tip turducken hamburger salami andouille meatloaf. Andouille landjaeger flank boudin beef short ribs brisket alcatra kielbasa ham pork loin pancetta. Pancetta tenderloin shoulder, porchetta tri-tip pastrami ham pork loin tail swine andouille. Sausage landjaeger strip steak tail corned beef biltong meatball picanha beef ribs swine kielbasa. T-bone tail rump kevin doner chuck. Prosciutto andouille pork loin shankle t-bone, turducken sirloin landjaeger pancetta picanha spare ribs filet mignon. Shank ham beef chuck salami tail t-bone shoulder beef ribs kevin.
+
Drumstick bacon turducken boudin ribeye cupim. Flank bresaola porchetta hamburger capicola. Sirloin tenderloin jowl, corned beef t-bone meatloaf swine pig. Swine ham hock beef ribs pork, strip steak rump picanha tail kielbasa turducken shank flank short loin chuck.
+
Prosciutto meatloaf t-bone shankle biltong, spare ribs pork belly pork cupim. Brisket pork loin kevin short loin cupim chuck jerky sirloin t-bone pig. Doner bresaola boudin beef frankfurter jowl t-bone ham hock strip steak turducken jerky leberkas alcatra flank shoulder. Tenderloin cupim hamburger, cow shoulder capicola jowl shankle swine pork loin meatloaf. Biltong drumstick meatloaf, cow pork belly ham hock pancetta alcatra landjaeger leberkas ball tip salami hamburger turkey.
+
Chuck kielbasa shoulder fatback venison pastrami, sausage rump cupim sirloin ham hock tail. Kevin prosciutto capicola brisket beef ribs chicken andouille. Spare ribs meatball kielbasa ribeye pork belly turkey ham. Ham hock beef ribs hamburger, bresaola pork biltong landjaeger. Ball tip picanha short ribs andouille chicken. Cow spare ribs bresaola tongue, ribeye hamburger biltong shank filet mignon drumstick brisket capicola rump short loin. Ham hock bacon sirloin kielbasa sausage doner shoulder.
+
Kielbasa cow tail pork, salami jowl leberkas kevin rump swine jerky. Strip steak turducken flank, jowl andouille bacon meatloaf venison alcatra short ribs prosciutto ribeye. Corned beef short loin leberkas tenderloin bresaola sausage pancetta frankfurter bacon. Turducken kevin landjaeger, corned beef bresaola picanha chuck. Ground round shoulder picanha pancetta, fatback shankle pork loin pastrami tri-tip.
+
Ribeye ham sirloin, ham hock short ribs flank ground round landjaeger brisket. Chicken prosciutto salami, bresaola capicola jowl ham hock filet mignon pork spare ribs doner biltong. Ball tip hamburger tongue, porchetta short loin meatball pork bresaola meatloaf fatback. Ham sausage ground round tongue pancetta beef ribs. Jerky cow tri-tip shank, tenderloin drumstick tongue ball tip strip steak leberkas pig. Sausage pork chop alcatra, boudin ground round picanha bresaola doner pancetta cow. Porchetta salami short ribs, drumstick ground round shank leberkas tail rump bacon andouille tenderloin sausage meatloaf chicken.
+
Salami tongue picanha, cupim cow ground round bacon turducken fatback meatloaf landjaeger leberkas kevin. Ground round kielbasa swine pork loin kevin ball tip. Shankle beef ribs venison biltong turkey, strip steak short ribs fatback kielbasa tenderloin pastrami ham hock ham. Salami bacon tail tongue pancetta cupim pastrami pork chop prosciutto brisket beef ribs. Swine salami ball tip tongue, turducken sausage pork belly frankfurter picanha capicola andouille meatloaf biltong short ribs hamburger. Shankle meatloaf tenderloin meatball, boudin ground round andouille cupim short loin filet mignon capicola. Boudin bresaola spare ribs meatloaf, alcatra bacon pork loin frankfurter prosciutto meatball pork belly salami.
+
Corned beef doner flank kevin. Alcatra ham hock kielbasa, pork loin turkey landjaeger bresaola shankle t-bone rump flank tenderloin beef. Meatball shank turducken leberkas t-bone. Ground round beef swine rump porchetta pork chop tri-tip pork loin kielbasa pastrami frankfurter pork andouille.
+
Turkey chicken tongue boudin cupim flank porchetta pastrami. Cow ham alcatra, porchetta turkey doner t-bone ribeye brisket spare ribs short ribs kielbasa. Ribeye ground round tenderloin beef ribs. Pancetta capicola porchetta ball tip doner drumstick boudin t-bone shankle. Pancetta flank leberkas, chicken tri-tip porchetta drumstick tail ribeye venison. Landjaeger alcatra turkey, picanha porchetta beef frankfurter meatball bacon pig short loin.
+
Filet mignon beef corned beef biltong doner, kielbasa prosciutto venison tenderloin. Shoulder bresaola t-bone pig tenderloin, meatball spare ribs leberkas tongue drumstick picanha rump ground round. Tongue short ribs pig salami rump, boudin andouille hamburger pancetta meatball. Filet mignon capicola pancetta cupim, shank jerky ham hock pork spare ribs strip steak short ribs rump alcatra. Shoulder short ribs picanha, chicken beef ham pork chop leberkas pastrami bresaola meatball salami. Salami pork chop ham hock pork meatloaf kielbasa turkey ribeye chicken tenderloin hamburger boudin frankfurter. Tri-tip hamburger short ribs short loin ham ball tip shoulder landjaeger tongue pig.
+
Flank pastrami sausage jerky cupim. Corned beef shankle boudin pancetta salami short ribs. Frankfurter beef ribs ribeye corned beef pastrami landjaeger flank meatloaf pork chop. Prosciutto pig frankfurter leberkas ham hock. Cupim flank tenderloin shank porchetta tail.
+
Bresaola beef ribs beef, tongue picanha sirloin short loin biltong. Short ribs leberkas jerky beef ribs tongue bacon pork chop. Meatloaf shankle short loin, jerky cupim chuck ground round biltong ham cow tenderloin. Sausage pancetta ribeye, venison doner landjaeger kielbasa bresaola. Leberkas tail andouille jowl spare ribs pork frankfurter pork belly salami sausage t-bone rump tongue. Flank chuck pork chop short ribs ball tip ham hock jerky shankle beef kielbasa prosciutto salami.
+
+
+
+
+
+
+
+
+
diff --git a/test/tests.js b/test/tests.js
new file mode 100644
index 0000000..321cc49
--- /dev/null
+++ b/test/tests.js
@@ -0,0 +1,24 @@
+/* globals QUnit: false */
+
+QUnit.module('filterPath');
+
+QUnit.test( 'Link paths not location path', function( assert ) {
+ var locationPath = $.smoothScroll.filterPath(location.pathname);
+ $('a[href*=#]').each(function() {
+ assert.notEqual(locationPath, this.pathname);
+ });
+});
+
+QUnit.module('scrollable');
+
+QUnit.test( 'Returns first scrollable element (html,body)', function( assert ) {
+ var scrollable = $('html,body').firstScrollable();
+ assert.equal(scrollable.length, 1, 'One scrollable element is returned');
+ assert.equal(scrollable[0], document.body, 'Scrollable element is ');
+});
+
+QUnit.test( 'Returns scrollable element (div#scrollable)', function( assert ) {
+ var scrollable = $('#scrollable').scrollable();
+ assert.equal(scrollable.length, 1, 'One scrollable element is returned');
+ assert.equal(scrollable[0].id, 'scrollable', 'Scrollable element is