]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Improvements
authorNordanne Isahac <den.isahac@gmail.com>
Thu, 19 Jan 2017 15:46:56 +0000 (23:46 +0800)
committerNordanne Isahac <den.isahac@gmail.com>
Thu, 19 Jan 2017 15:46:56 +0000 (23:46 +0800)
docs/pages/smooth-scroll.md
js/foundation.smoothScroll.js

index 59327576f7f747f8e566f2a8b6d538bcc792369e..54faacc9bf2b3b111f85eec648fe41155e01c98a 100644 (file)
@@ -6,16 +6,9 @@ tags:
   - navigation
 ---
 
-<ul class="menu vertical" data-smooth-scroll>
-  <li><a href="#setup">Setup</a></li>
-  <li><a href="#javascript-reference">Javascript Reference</a></li>
-</ul>
-
-<br>
-
-## Setup
+## Usage
 
-To enable SmoothScroll on internal links, just add the attribute `data-smooth-scroll` to the parent container like our [Menu](menu.html). Each section needs a unique ID
+To enable smooth scrolling on internal links add the attribute `data-smooth-scroll` to the parent container like our [Menu](menu.html). Each section needs a unique ID
 
 ```html
 <ul class="horizontal menu" data-smooth-scroll>
@@ -30,7 +23,7 @@ To enable SmoothScroll on internal links, just add the attribute `data-smooth-sc
 </div>
 ```
 
-You can also setup SmoothScroll directly via indiviual link.
+You can also apply `data-smooth-scroll` attribute directly to the link.
 
 ```html
 <a href="#exclusive" data-smooth-scroll>Exclusive Section</a>
index f81a8a14c1f4b49409859ff7cc3b6d1fa1d3273c..b749516c3bdc2336cd2847a31912ae5c70a141b7 100644 (file)
@@ -62,17 +62,19 @@ class SmoothScroll {
     /**
      * Function to scroll to a given location on the page.
      * @param {String} loc - A properly formatted jQuery id selector. Example: '#foo'
-     * @param {Object} options - The options to use.
-     * @param {Function} callback - The callback function.
+     * @param {Object} options - Overrides to the default plugin settings.
+     * @param {Function} callback - The callback function when scroll animation is finished.
      * @static
      * @function
      */
-    static scrollToLoc(loc, options = SmoothScroll.defaults, callback) {
+    static scrollToLoc(loc, options, callback) {
         // Do nothing if target does not exist to prevent errors
         if (!$(loc).length) {
             return false;
         }
 
+        options = $.extend({}, SmoothScroll.defaults, options);
+
         var scrollPos = Math.round($(loc).offset().top - options.threshold / 2 - options.offset);
 
         $('html, body').stop(true).animate(