Skip to content

Commit e73a51d

Browse files
committed
Build and bump to 2.2
1 parent 6365a12 commit e73a51d

6 files changed

+52
-27
lines changed

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "jquery-smooth-scroll",
44
"main": "jquery.smooth-scroll.js",
55
"homepage": "https://github.com/kswedberg/jquery-smooth-scroll",
6-
"version": "2.1.2",
6+
"version": "2.2.0",
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/kswedberg/jquery-smooth-scroll"
@@ -22,7 +22,7 @@
2222
{
2323
"name": "Karl Swedberg",
2424
"email": "kswedberg@gmail.com",
25-
"url": "http://www.learningjquery.com/"
25+
"url": "https://karlswedberg.com/"
2626
}
2727
],
2828
"moduleType": [

index.html

Lines changed: 22 additions & 17 deletions
Large diffs are not rendered by default.

jquery.smooth-scroll.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery Smooth Scroll - v2.1.2 - 2017-01-19
2+
* jQuery Smooth Scroll - v2.2.0 - 2017-05-05
33
* https://github.com/kswedberg/jquery-smooth-scroll
44
* Copyright (c) 2017 Karl Swedberg
55
* Licensed MIT
@@ -18,7 +18,7 @@
1818
}
1919
}(function($) {
2020

21-
var version = '2.1.2';
21+
var version = '2.2.0';
2222
var optionOverrides = {};
2323
var defaults = {
2424
exclude: [],
@@ -39,6 +39,9 @@
3939
// only use if you want to override default behavior
4040
scrollTarget: null,
4141

42+
// automatically focus the target element after scrolling to it
43+
autoFocus: false,
44+
4245
// fn(opts) function to be called before scrolling occurs.
4346
// `this` is the element(s) being scrolled
4447
beforeScroll: function() {},
@@ -125,6 +128,7 @@
125128
};
126129

127130
var rRelative = /^([\-\+]=)(\d+)/;
131+
128132
$.fn.extend({
129133
scrollable: function(dir) {
130134
var scrl = getScrollable.call(this, {dir: dir});
@@ -237,6 +241,21 @@
237241
return explicit;
238242
};
239243

244+
var onAfterScroll = function(opts) {
245+
var $tgt = $(opts.scrollTarget);
246+
247+
if (opts.autoFocus && $tgt.length) {
248+
$tgt[0].focus();
249+
250+
if (!$tgt.is(document.activeElement)) {
251+
$tgt.prop({tabIndex: -1});
252+
$tgt[0].focus();
253+
}
254+
}
255+
256+
opts.afterScroll.call(opts.link, opts);
257+
};
258+
240259
$.smoothScroll = function(options, px) {
241260
if (options === 'options' && typeof px === 'object') {
242261
return $.extend(optionOverrides, px);
@@ -307,7 +326,7 @@
307326
duration: speed,
308327
easing: opts.easing,
309328
complete: function() {
310-
opts.afterScroll.call(opts.link, opts);
329+
onAfterScroll(opts);
311330
}
312331
};
313332

@@ -318,7 +337,7 @@
318337
if ($scroller.length) {
319338
$scroller.stop().animate(aniProps, aniOpts);
320339
} else {
321-
opts.afterScroll.call(opts.link, opts);
340+
onAfterScroll(opts);
322341
}
323342
};
324343

jquery.smooth-scroll.min.js

Lines changed: 3 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: 1 addition & 1 deletion
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": "2.1.2",
4+
"version": "2.2.0",
55
"scripts": {},
66
"main": "jquery.smooth-scroll.js",
77
"author": {

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

0 commit comments

Comments
 (0)