Skip to content

Commit e25ce35

Browse files
committed
fixed issue with firstScrollable pushing the wrong elements onto the stack
1 parent 063dbb9 commit e25ce35

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

jquery.smooth-scroll.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ var version = '1.3';
2020

2121
var locationPath = filterPath(location.pathname);
2222

23-
$.fn.extend({
24-
scrollable: function() {
23+
function getScrollable(els) {
2524
var scrollable = [], scrolled = false;
25+
2626
this.each(function() {
2727

2828
if (this == document || this == window) { return; }
@@ -42,10 +42,20 @@ $.fn.extend({
4242

4343
});
4444

45-
return this.pushStack(scrollable);
45+
if ( els === 'first' && scrollable.length ) {
46+
scrollable = [ scrollable.shift() ];
47+
}
48+
49+
return scrollable;
50+
}
51+
$.fn.extend({
52+
scrollable: function() {
53+
var scrl = getScrollable.call(this);
54+
return this.pushStack(scrl);
4655
},
4756
firstScrollable: function() {
48-
return this.scrollable().eq(0);
57+
var scrl = getScrollable.call(this, 'first');
58+
return this.pushStack(scrl);
4959
},
5060

5161
smoothScroll: function(options) {

0 commit comments

Comments
 (0)