Skip to content

Commit 13a391f

Browse files
committed
Merge pull request cferdinandi#230 from cferdinandi/development
v9.0.1
2 parents 9d2a804 + cb5b1e3 commit 13a391f

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

dist/js/smooth-scroll.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v9.0.0: Animate scrolling to anchor links
2+
* smooth-scroll v9.0.1: Animate scrolling to anchor links
33
* (c) 2016 Chris Ferdinandi
44
* MIT License
55
* http://github.com/cferdinandi/smooth-scroll
@@ -23,7 +23,7 @@
2323

2424
var smoothScroll = {}; // Object for public APIs
2525
var supports = 'querySelector' in document && 'addEventListener' in root; // Feature test
26-
var settings, eventTimeout, fixedHeader, headerHeight;
26+
var settings, eventTimeout, fixedHeader, headerHeight, animationInterval;
2727

2828
// Default settings
2929
var defaults = {
@@ -341,6 +341,8 @@
341341
*/
342342
smoothScroll.animateScroll = function ( anchor, toggle, options ) {
343343

344+
// if ( scrolling ) return;
345+
344346
// Options and overrides
345347
var overrides = getDataOptions( toggle ? toggle.getAttribute('data-options') : null );
346348
var settings = extend( settings || defaults, options || {}, overrides ); // Merge user options with defaults
@@ -354,7 +356,6 @@
354356
if ( !fixedHeader ) { fixedHeader = root.document.querySelector( settings.selectorHeader ); } // Get the fixed header if not already set
355357
if ( !headerHeight ) { headerHeight = getHeaderHeight( fixedHeader ); } // Get the height of a fixed header if one exists and not already set
356358
var endLocation = isNum ? anchor : getEndLocation( anchorElem, headerHeight, parseInt(settings.offset, 10) ); // Location to scroll to
357-
var animationInterval; // interval timer
358359
var distance = endLocation - startLocation; // distance to travel
359360
var documentHeight = getDocumentHeight();
360361
var timeLapsed = 0;
@@ -401,6 +402,7 @@
401402
* @private
402403
*/
403404
var startAnimateScroll = function () {
405+
clearInterval(animationInterval);
404406
animationInterval = setInterval(loopAnimateScroll, 16);
405407
};
406408

@@ -463,6 +465,7 @@
463465
eventTimeout = null;
464466
fixedHeader = null;
465467
headerHeight = null;
468+
animationInterval = null;
466469
};
467470

468471
/**

dist/js/smooth-scroll.min.js

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

docs/dist/js/smooth-scroll.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* smooth-scroll v9.0.0: Animate scrolling to anchor links
2+
* smooth-scroll v9.0.1: Animate scrolling to anchor links
33
* (c) 2016 Chris Ferdinandi
44
* MIT License
55
* http://github.com/cferdinandi/smooth-scroll
@@ -23,7 +23,7 @@
2323

2424
var smoothScroll = {}; // Object for public APIs
2525
var supports = 'querySelector' in document && 'addEventListener' in root; // Feature test
26-
var settings, eventTimeout, fixedHeader, headerHeight;
26+
var settings, eventTimeout, fixedHeader, headerHeight, animationInterval;
2727

2828
// Default settings
2929
var defaults = {
@@ -341,6 +341,8 @@
341341
*/
342342
smoothScroll.animateScroll = function ( anchor, toggle, options ) {
343343

344+
// if ( scrolling ) return;
345+
344346
// Options and overrides
345347
var overrides = getDataOptions( toggle ? toggle.getAttribute('data-options') : null );
346348
var settings = extend( settings || defaults, options || {}, overrides ); // Merge user options with defaults
@@ -354,7 +356,6 @@
354356
if ( !fixedHeader ) { fixedHeader = root.document.querySelector( settings.selectorHeader ); } // Get the fixed header if not already set
355357
if ( !headerHeight ) { headerHeight = getHeaderHeight( fixedHeader ); } // Get the height of a fixed header if one exists and not already set
356358
var endLocation = isNum ? anchor : getEndLocation( anchorElem, headerHeight, parseInt(settings.offset, 10) ); // Location to scroll to
357-
var animationInterval; // interval timer
358359
var distance = endLocation - startLocation; // distance to travel
359360
var documentHeight = getDocumentHeight();
360361
var timeLapsed = 0;
@@ -401,6 +402,7 @@
401402
* @private
402403
*/
403404
var startAnimateScroll = function () {
405+
clearInterval(animationInterval);
404406
animationInterval = setInterval(loopAnimateScroll, 16);
405407
};
406408

@@ -463,6 +465,7 @@
463465
eventTimeout = null;
464466
fixedHeader = null;
465467
headerHeight = null;
468+
animationInterval = null;
466469
};
467470

468471
/**

0 commit comments

Comments
 (0)