Skip to content

Commit 48f11a2

Browse files
committed
Release 1.4.2
1 parent b469846 commit 48f11a2

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

demo/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<li><a href="#p3">p3</a></li>
7070
<li><a href="#p4">p4</a></li>
7171
<li><a href="#p5">p5</a></li>
72+
<li><a href="bbq.html#p5">bbq.html#p5</a></li>
7273
</ul>
7374
<p>Or, <a href="bbq.html">try it with hashchange support</a></p>
7475
<button class="scrollsomething">Scroll vertically</button>

jquery.smooth-scroll.js

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
2-
* jQuery Smooth Scroll Plugin v1.4.1
2+
* jQuery Smooth Scroll Plugin v1.4.2
33
*
4-
* Date: Tue Nov 15 14:24:14 2011 EST
4+
* Date: Tue Feb 14 17:34:02 2012 EST
55
* Requires: jQuery v1.3+
66
*
77
* Copyright 2010, Karl Swedberg
@@ -16,7 +16,7 @@
1616

1717
(function($) {
1818

19-
var version = '1.4.1',
19+
var version = '1.4.2',
2020
defaults = {
2121
exclude: [],
2222
excludeWithin:[],
@@ -30,6 +30,7 @@ var version = '1.4.1',
3030
easing: 'swing',
3131
speed: 400
3232
},
33+
3334
locationPath = filterPath(location.pathname),
3435
getScrollable = function(opts) {
3536
var scrollable = [],
@@ -60,7 +61,8 @@ var version = '1.4.1',
6061
}
6162

6263
return scrollable;
63-
};
64+
},
65+
isTouch = 'ontouchend' in document;
6466

6567
$.fn.extend({
6668
scrollable: function(dir) {
@@ -123,7 +125,9 @@ $.smoothScroll = function(options, px) {
123125
scrollerOffset = 0,
124126
offPos = 'offset',
125127
scrollDir = 'scrollTop',
126-
aniprops = {};
128+
aniprops = {},
129+
useScrollTo = false,
130+
scrollprops = [];
127131

128132
if ( typeof options === 'number') {
129133
opts = $.fn.smoothScroll.defaults;
@@ -150,6 +154,7 @@ $.smoothScroll = function(options, px) {
150154
scrollerOffset = $scroller[scrollDir]();
151155
} else {
152156
$scroller = $('html, body').firstScrollable();
157+
useScrollTo = isTouch && 'scrollTo' in window;
153158
}
154159

155160
aniprops[scrollDir] = scrollTargetOffset + scrollerOffset + opts.offset;
@@ -158,16 +163,21 @@ $.smoothScroll = function(options, px) {
158163
opts.beforeScroll.call($scroller, opts);
159164
}
160165

161-
$scroller.animate(aniprops,
162-
{
163-
duration: opts.speed,
164-
easing: opts.easing,
165-
complete: function() {
166-
if ( opts.afterScroll && $.isFunction(opts.afterScroll) ) {
167-
opts.afterScroll.call(opts.link, opts);
166+
if ( useScrollTo ) {
167+
scrollprops = (opts.direction == 'left') ? [aniprops[scrollDir], 0] : [0, aniprops[scrollDir]];
168+
window.scrollTo.apply(window, scrollprops);
169+
} else {
170+
$scroller.animate(aniprops,
171+
{
172+
duration: opts.speed,
173+
easing: opts.easing,
174+
complete: function() {
175+
if ( opts.afterScroll && $.isFunction(opts.afterScroll) ) {
176+
opts.afterScroll.call(opts.link, opts);
177+
}
168178
}
169-
}
170-
});
179+
});
180+
}
171181

172182
};
173183

jquery.smooth-scroll.min.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)