1
1
/*!
2
- * jQuery Smooth Scroll Plugin v1.4.4
2
+ * jQuery Smooth Scroll Plugin v1.4.5
3
3
*
4
- * Date: Mon Feb 20 09:04:54 2012 EST
4
+ * Date: Sun Mar 11 18:17:42 2012 EDT
5
5
* Requires: jQuery v1.3+
6
6
*
7
- * Copyright 2010 , Karl Swedberg
7
+ * Copyright 2012 , Karl Swedberg
8
8
* Dual licensed under the MIT and GPL licenses (just like jQuery):
9
9
* http://www.opensource.org/licenses/mit-license.php
10
10
* http://www.gnu.org/licenses/gpl.html
@@ -29,7 +29,7 @@ var version = '1.4.4',
29
29
afterScroll : function ( ) { } , // fn(opts) function to be called after scrolling occurs. "this" is the triggering element
30
30
easing : 'swing' ,
31
31
speed : 400 ,
32
- auto_coeff : 2 // coefficient for "auto" speed
32
+ autoCoefficent : 2 // coefficient for "auto" speed
33
33
} ,
34
34
35
35
getScrollable = function ( opts ) {
@@ -123,7 +123,7 @@ $.fn.extend({
123
123
} ) ;
124
124
125
125
$ . smoothScroll = function ( options , px ) {
126
- var opts , $scroller , scrollTargetOffset ,
126
+ var opts , $scroller , scrollTargetOffset , speed ,
127
127
scrollerOffset = 0 ,
128
128
offPos = 'offset' ,
129
129
scrollDir = 'scrollTop' ,
@@ -169,21 +169,19 @@ $.smoothScroll = function(options, px) {
169
169
opts . afterScroll . call ( opts . link , opts ) ;
170
170
171
171
} else {
172
- var speed ;
173
- if ( opts . speed === 'auto' ) {
174
- if ( aniprops [ scrollDir ] === 0 ) {
175
- speed = $ ( 'html' ) . scrollTop ( ) ;
176
- } else {
177
- speed = aniprops [ scrollDir ] ;
178
- }
179
- speed = speed / opts . auto_coeff ;
180
- } else {
181
- speed = opts . speed ;
172
+ speed = opts . speed ;
173
+
174
+ // automatically calculate the speed of the scroll based on distance / coefficient
175
+ if ( speed === 'auto' ) {
176
+ // if aniprops[scrollDir] == 0 then we'll use scrollTop() value instead
177
+ speed = aniprops [ scrollDir ] || $scroller . scrollTop ( ) ;
178
+ // divide the speed by the coefficient
179
+ speed = speed / opts . autoCoefficent ;
182
180
}
183
181
184
182
$scroller . animate ( aniprops ,
185
183
{
186
- duration : opts . speed ,
184
+ duration : speed ,
187
185
easing : opts . easing ,
188
186
complete : function ( ) {
189
187
opts . afterScroll . call ( opts . link , opts ) ;
0 commit comments