Skip to content

Commit

Permalink
Build and bump to 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kswedberg committed May 5, 2017
1 parent 6365a12 commit e73a51d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "jquery-smooth-scroll",
"main": "jquery.smooth-scroll.js",
"homepage": "https://github.com/kswedberg/jquery-smooth-scroll",
"version": "2.1.2",
"version": "2.2.0",
"repository": {
"type": "git",
"url": "https://github.com/kswedberg/jquery-smooth-scroll"
Expand All @@ -22,7 +22,7 @@
{
"name": "Karl Swedberg",
"email": "[email protected]",
"url": "http://www.learningjquery.com/"
"url": "https://karlswedberg.com/"
}
],
"moduleType": [
Expand Down
39 changes: 22 additions & 17 deletions index.html

Large diffs are not rendered by default.

27 changes: 23 additions & 4 deletions jquery.smooth-scroll.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jQuery Smooth Scroll - v2.1.2 - 2017-01-19
* jQuery Smooth Scroll - v2.2.0 - 2017-05-05
* https://github.com/kswedberg/jquery-smooth-scroll
* Copyright (c) 2017 Karl Swedberg
* Licensed MIT
Expand All @@ -18,7 +18,7 @@
}
}(function($) {

var version = '2.1.2';
var version = '2.2.0';
var optionOverrides = {};
var defaults = {
exclude: [],
Expand All @@ -39,6 +39,9 @@
// only use if you want to override default behavior
scrollTarget: null,

// automatically focus the target element after scrolling to it
autoFocus: false,

// fn(opts) function to be called before scrolling occurs.
// `this` is the element(s) being scrolled
beforeScroll: function() {},
Expand Down Expand Up @@ -125,6 +128,7 @@
};

var rRelative = /^([\-\+]=)(\d+)/;

$.fn.extend({
scrollable: function(dir) {
var scrl = getScrollable.call(this, {dir: dir});
Expand Down Expand Up @@ -237,6 +241,21 @@
return explicit;
};

var onAfterScroll = function(opts) {
var $tgt = $(opts.scrollTarget);

if (opts.autoFocus && $tgt.length) {
$tgt[0].focus();

if (!$tgt.is(document.activeElement)) {
$tgt.prop({tabIndex: -1});
$tgt[0].focus();
}
}

opts.afterScroll.call(opts.link, opts);
};

$.smoothScroll = function(options, px) {
if (options === 'options' && typeof px === 'object') {
return $.extend(optionOverrides, px);
Expand Down Expand Up @@ -307,7 +326,7 @@
duration: speed,
easing: opts.easing,
complete: function() {
opts.afterScroll.call(opts.link, opts);
onAfterScroll(opts);
}
};

Expand All @@ -318,7 +337,7 @@
if ($scroller.length) {
$scroller.stop().animate(aniProps, aniOpts);
} else {
opts.afterScroll.call(opts.link, opts);
onAfterScroll(opts);
}
};

Expand Down
5 changes: 3 additions & 2 deletions jquery.smooth-scroll.min.js

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

2 changes: 1 addition & 1 deletion 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": "2.1.2",
"version": "2.2.0",
"scripts": {},
"main": "jquery.smooth-scroll.js",
"author": {
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 = '2.1.2';
var version = '2.2.0';
var optionOverrides = {};
var defaults = {
exclude: [],
Expand Down

0 comments on commit e73a51d

Please sign in to comment.