Skip to content

Commit 383e16d

Browse files
author
Chris Ferdinandi
committed
Converted _defaults to a literal object
1 parent 6fbb65e commit 383e16d

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ Smooth Scroll is licensed under the [MIT License](http://gomakethings.com/mit/).
175175

176176

177177
## Changelog
178+
* v4.1 - February 27, 2014
179+
* Converted `_defaults` to a literal object
178180
* v4.0 - February 21, 2014
179181
* Better public/private method namespacing.
180182
* Require `init()` call to run.

smooth-scroll.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* =============================================================
22
3-
Smooth Scroll v4.0
3+
Smooth Scroll v4.1
44
Animate scrolling to anchor links, by Chris Ferdinandi.
55
http://gomakethings.com
66
@@ -17,16 +17,13 @@ window.smoothScroll = (function (window, document, undefined) {
1717
'use strict';
1818

1919
// Default settings
20-
// Private method
21-
// Returns an {object}
22-
var _defaults = function () {
23-
return {
24-
speed: 500,
25-
easing: 'easeInOutCubic',
26-
updateURL: false,
27-
callbackBefore: function () {},
28-
callbackAfter: function () {}
29-
};
20+
// Private {object} variable
21+
var _defaults = {
22+
speed: 500,
23+
easing: 'easeInOutCubic',
24+
updateURL: false,
25+
callbackBefore: function () {},
26+
callbackAfter: function () {}
3027
};
3128

3229
// Merge default settings with user options
@@ -117,7 +114,7 @@ window.smoothScroll = (function (window, document, undefined) {
117114
var animateScroll = function ( toggle, anchor, options, event ) {
118115

119116
// Options and overrides
120-
options = _mergeObjects( _defaults(), options || {} ); // Merge user options with defaults
117+
options = _mergeObjects( _defaults, options || {} ); // Merge user options with defaults
121118
var overrides = _getDataOptions( toggle.getAttribute('data-options') );
122119
var speed = overrides.speed || options.speed;
123120
var easing = overrides.easing || options.easing;
@@ -186,7 +183,7 @@ window.smoothScroll = (function (window, document, undefined) {
186183
if ( 'querySelector' in document && 'addEventListener' in window && Array.prototype.forEach ) {
187184

188185
// Selectors and variables
189-
options = _mergeObjects( _defaults(), options || {} ); // Merge user options with defaults
186+
options = _mergeObjects( _defaults, options || {} ); // Merge user options with defaults
190187
var toggles = document.querySelectorAll('[data-scroll]'); // Get smooth scroll toggles
191188

192189
// When a toggle is clicked, run the click handler

0 commit comments

Comments
 (0)