Skip to content

Commit da9dc97

Browse files
committed
Release 1.5.0
1 parent 252e4a5 commit da9dc97

File tree

7 files changed

+88
-52
lines changed

7 files changed

+88
-52
lines changed

Gruntfile.js

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
module.exports = function(grunt) {
44

5-
// Because I'm lazy
6-
var _ = grunt.util._;
75
var marked = require('marked');
86
// var hl = require('highlight').Highlight;
97
var hl = require('node-syntaxhighlighter');
@@ -20,7 +18,7 @@ module.exports = function(grunt) {
2018
// Project configuration.
2119
grunt.initConfig({
2220
bower: './bower.json',
23-
pkg: grunt.file.readJSON('smooth-scroll.jquery.json'),
21+
pkg: grunt.file.readJSON('package.json'),
2422
meta: {
2523
banner: '/*!<%= "\\n" %>' +
2624
' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
@@ -150,29 +148,32 @@ module.exports = function(grunt) {
150148

151149
grunt.registerTask( 'deploy', ['setshell:rsync', 'shell:rsync']);
152150

153-
grunt.registerTask( 'bower', 'Update bower.json', function() {
154-
var comp = grunt.config('bower'),
155-
pkgName = grunt.config('pkg').name,
156-
pkg = grunt.file.readJSON(pkgName + '.jquery.json'),
157-
json = {};
158-
159-
['name', 'version', 'dependencies'].forEach(function(el) {
160-
json[el] = pkg[el];
151+
grunt.registerTask( 'configs', 'Update json configs based on package.json', function() {
152+
var rjQuery = /^jquery\./,
153+
bowerFile = grunt.config('bower'),
154+
bower = grunt.file.readJSON(bowerFile),
155+
pkg = grunt.config('pkg'),
156+
jqConfigFile = pkg.name.replace(rjQuery, '') + '.jquery.json',
157+
jqConfig = grunt.file.readJSON(jqConfigFile);
158+
159+
['name', 'main', 'version', 'dependencies', 'keywords'].forEach(function(el) {
160+
bower[el] = pkg[el];
161+
jqConfig[el] = pkg[el];
161162
});
162163

163-
_.extend(json, {
164-
main: grunt.config('concat.all.dest'),
165-
ignore: [
166-
'demo/',
167-
'lib/',
168-
'src/',
169-
'*.json'
170-
]
164+
165+
['author', 'repository', 'homepage', 'docs', 'bugs', 'demo', 'licenses'].forEach(function(el) {
166+
jqConfig[el] = pkg[el];
171167
});
172-
json.name = 'jquery.' + json.name;
173168

174-
grunt.file.write( comp, JSON.stringify(json, null, 2) );
175-
grunt.log.writeln( 'File "' + comp + '" updated."' );
169+
jqConfig.keywords.shift();
170+
jqConfig.name = jqConfig.name.replace(rjQuery, '');
171+
172+
grunt.file.write( bowerFile, JSON.stringify(bower, null, 2) + '\n');
173+
grunt.log.writeln( 'File "' + bowerFile + '" updated."' );
174+
175+
grunt.file.write( jqConfigFile, JSON.stringify(jqConfig, null, 2) + '\n');
176+
grunt.log.writeln( 'File "' + jqConfigFile + '" updated."' );
176177
});
177178

178179
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) {
185186
grunt.file.write('index.html', head + doc + foot);
186187
});
187188

188-
grunt.registerTask('build', ['jshint', 'concat', 'version:same', 'bower', 'uglify', 'docs']);
189-
grunt.registerTask('patch', ['jshint', 'concat', 'version:bannerPatch', 'version:patch', 'bower', 'uglify']);
189+
grunt.registerTask('build', ['jshint', 'concat', 'version:same', 'configs', 'uglify', 'docs']);
190+
grunt.registerTask('patch', ['jshint', 'concat', 'version:bannerPatch', 'version:patch', 'configs', 'uglify']);
190191
grunt.registerTask('default', ['build']);
191192

192193
grunt.loadNpmTasks('grunt-contrib-jshint');

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery.smooth-scroll",
3-
"version": "1.4.13",
3+
"version": "1.5.0",
44
"dependencies": {
55
"jquery": ">=1.3"
66
},

jquery.smooth-scroll.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*!
2-
* Smooth Scroll - v1.4.13 - 2013-11-02
2+
* Smooth Scroll - v1.5.0 - 2014-08-11
33
* https://github.com/kswedberg/jquery-smooth-scroll
4-
* Copyright (c) 2013 Karl Swedberg
4+
* Copyright (c) 2014 Karl Swedberg
55
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
66
*/
77

88
(function($) {
9-
var version = '1.4.13',
9+
var version = '1.5.0',
1010
optionOverrides = {},
1111
defaults = {
1212
exclude: [],
@@ -34,7 +34,7 @@ var version = '1.4.13',
3434
speed: 400,
3535

3636
// coefficient for "auto" speed
37-
autoCoefficent: 2,
37+
autoCoefficient: 2,
3838

3939
// $.fn.smoothScroll only: whether to prevent the default click action
4040
preventDefault: true
@@ -43,11 +43,11 @@ var version = '1.4.13',
4343
getScrollable = function(opts) {
4444
var scrollable = [],
4545
scrolled = false,
46-
dir = opts.dir && opts.dir == 'left' ? 'scrollLeft' : 'scrollTop';
46+
dir = opts.dir && opts.dir === 'left' ? 'scrollLeft' : 'scrollTop';
4747

4848
this.each(function() {
4949

50-
if (this == document || this == window) { return; }
50+
if (this === document || this === window) { return; }
5151
var el = $(this);
5252
if ( el[dir]() > 0 ) {
5353
scrollable.push(this);
@@ -68,7 +68,7 @@ var version = '1.4.13',
6868
// (doing this because Safari sets scrollTop async,
6969
// so can't set it to 1 and immediately get the value.)
7070
if (!scrollable.length) {
71-
this.each(function(index) {
71+
this.each(function() {
7272
if (this.nodeName === 'BODY') {
7373
scrollable = [this];
7474
}
@@ -81,8 +81,7 @@ var version = '1.4.13',
8181
}
8282

8383
return scrollable;
84-
},
85-
isTouch = 'ontouchend' in document;
84+
};
8685

8786
$.fn.extend({
8887
scrollable: function(dir) {
@@ -152,6 +151,7 @@ $.fn.extend({
152151
scrollTarget: thisOpts.scrollTarget || thisHash,
153152
link: link
154153
});
154+
155155
$.smoothScroll( clickOpts );
156156
}
157157
});
@@ -164,13 +164,12 @@ $.smoothScroll = function(options, px) {
164164
if ( options === 'options' && typeof px === 'object' ) {
165165
return $.extend(optionOverrides, px);
166166
}
167-
var opts, $scroller, scrollTargetOffset, speed,
167+
var opts, $scroller, scrollTargetOffset, speed, delta,
168168
scrollerOffset = 0,
169169
offPos = 'offset',
170170
scrollDir = 'scrollTop',
171171
aniProps = {},
172-
aniOpts = {},
173-
scrollprops = [];
172+
aniOpts = {};
174173

175174
if (typeof options === 'number') {
176175
opts = $.extend({link: null}, $.fn.smoothScroll.defaults, optionOverrides);
@@ -179,13 +178,13 @@ $.smoothScroll = function(options, px) {
179178
opts = $.extend({link: null}, $.fn.smoothScroll.defaults, options || {}, optionOverrides);
180179
if (opts.scrollElement) {
181180
offPos = 'position';
182-
if (opts.scrollElement.css('position') == 'static') {
181+
if (opts.scrollElement.css('position') === 'static') {
183182
opts.scrollElement.css('position', 'relative');
184183
}
185184
}
186185
}
187186

188-
scrollDir = opts.direction == 'left' ? 'scrollLeft' : scrollDir;
187+
scrollDir = opts.direction === 'left' ? 'scrollLeft' : scrollDir;
189188

190189
if ( opts.scrollElement ) {
191190
$scroller = opts.scrollElement;
@@ -211,11 +210,15 @@ $.smoothScroll = function(options, px) {
211210
// automatically calculate the speed of the scroll based on distance / coefficient
212211
if (speed === 'auto') {
213212

214-
// if aniProps[scrollDir] == 0 then we'll use scrollTop() value instead
215-
speed = aniProps[scrollDir] || $scroller.scrollTop();
213+
// $scroller.scrollTop() is position before scroll, aniProps[scrollDir] is position after
214+
// When delta is greater, speed will be greater.
215+
delta = aniProps[scrollDir] - $scroller.scrollTop();
216+
if(delta < 0) {
217+
delta *= -1;
218+
}
216219

217-
// divide the speed by the coefficient
218-
speed = speed / opts.autoCoefficent;
220+
// Divide the delta by the coefficient
221+
speed = delta / opts.autoCoefficient;
219222
}
220223

221224
aniOpts = {
@@ -239,6 +242,7 @@ $.smoothScroll = function(options, px) {
239242

240243
$.smoothScroll.version = version;
241244
$.smoothScroll.filterPath = function(string) {
245+
string = string || '';
242246
return string
243247
.replace(/^\//,'')
244248
.replace(/(?:index|default).[a-zA-Z]{3,4}$/,'')

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: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
{
2-
"name": "smooth-scroll",
3-
"version": "1.4.13",
2+
"name": "jquery.smooth-scroll",
3+
"version": "1.5.0",
44
"scripts": {
55
"test": "./node_modules/.bin/grunt"
66
},
7-
"dependencies": {},
7+
"main": "jquery.smooth-scroll.js",
8+
"author": {
9+
"name": "Karl Swedberg",
10+
"email": "kswedberg@gmail.com",
11+
"url": "http://www.learningjquery.com/"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/kswedberg/jquery-smooth-scroll"
16+
},
17+
"homepage": "https://github.com/kswedberg/jquery-smooth-scroll",
18+
"docs": "https://github.com/kswedberg/jquery-smooth-scroll",
19+
"bugs": "https://github.com/kswedberg/jquery-smooth-scroll/issues",
20+
"demo": "http://plugins.learningjquery.com/smooth-scroll/demo/",
21+
"licenses": [
22+
{
23+
"type": "MIT",
24+
"url": "https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT"
25+
}
26+
],
27+
"dependencies": {
28+
"jquery": ">=1.3"
29+
},
830
"devDependencies": {
931
"grunt": "~0.4.0",
1032
"grunt-contrib-concat": "~0.1.2",
@@ -16,5 +38,10 @@
1638
"marked": "^0.3.2",
1739
"node-syntaxhighlighter": "~0.8.1"
1840
},
41+
"keywords": [
42+
"jQuery",
43+
"scroll",
44+
"animation"
45+
],
1946
"readmeFilename": "readme.md"
2047
}

smooth-scroll.jquery.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "smooth-scroll",
3-
"version": "1.4.13",
3+
"version": "1.5.0",
44
"title": "Smooth Scroll",
55
"description": "Easy implementation of smooth scrolling for same-page links",
66
"author": {
@@ -25,5 +25,9 @@
2525
"dependencies": {
2626
"jquery": ">=1.3"
2727
},
28-
"keywords": ["scroll", "animation"]
28+
"keywords": [
29+
"scroll",
30+
"animation"
31+
],
32+
"main": "jquery.smooth-scroll.js"
2933
}

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

0 commit comments

Comments
 (0)