Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions jquery.smooth-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,15 @@ $.smoothScroll = function(options, px) {
// automatically calculate the speed of the scroll based on distance / coefficient
if (speed === 'auto') {

// if aniProps[scrollDir] == 0 then we'll use scrollTop() value instead
speed = aniProps[scrollDir] || $scroller.scrollTop();
// $scroller.scrollTop() is brefore scroll, aniProps[scrollDir] is after scroll
//'delta' is value changing. When 'delta' bigger, then 'speed' will be larger same and vice versa.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion for comment text:
//'delta' is a storage variable for the difference in offsets between // $scroller.scrollTop() , and aniProps[scrollDir] .

var delta = aniProps[scrollDir] - $scroller.scrollTop();
if(delta < 0) {
delta *= -1;
}

// divide the speed by the coefficient
speed = speed / opts.autoCoefficent;
speed = delta / opts.autoCoefficent;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sake of consistancy of format:
var speed = delta / opts.autoCoefficent;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@travco, it's actually good as is. speed is already declared within that scope, so no need to do so again.

}

aniOpts = {
Expand Down