]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
adds missing .data() to options in magellan, adds option for offsetting scroll positi...
authorzurbchris <chris@zurb.com>
Tue, 1 Dec 2015 23:44:50 +0000 (15:44 -0800)
committerzurbchris <chris@zurb.com>
Tue, 1 Dec 2015 23:44:50 +0000 (15:44 -0800)
docs/pages/magellan.md
js/foundation.magellan.js

index 0512a27ec14333c8f9ba130b7eda8dc26bf6519a..c29fcf3cbfc89cb8d2dde207a62650d47aff6bf0 100644 (file)
@@ -7,7 +7,7 @@ tags:
 ---
 <div data-sticky-container>
   <div class="sticky" id="sticky-magellan" style="width:100%;" data-sticky data-margin-top="0" data-margin-bottom="0" data-top-anchor="setup" data-btm-anchor="destroy:bottom">
-    <nav data-magellan class="sticky-mag">
+    <nav data-magellan class="sticky-mag" data-bar-offset="25">
       <ul class="horizontal menu expanded">
         <li><a href="#setup">Setup</a></li>
         <li><a href="#sticky-navigation">Sticky Navigation</a></li>
index b97091d979a0a42632d808edb0f0fa5167c55285..a9620337cd2da41280e3dfbca20f80960e10a01c 100644 (file)
@@ -14,7 +14,7 @@
    */
   function Magellan(element, options) {
     this.$element = element;
-    this.options  = $.extend({}, Magellan.defaults, options);
+    this.options  = $.extend({}, Magellan.defaults, this.$element.data(), options);
 
     this._init();
 
      * @option
      * @example true
      */
-    deepLinking: false
+    deepLinking: false,
+    /**
+     * Number of pixels to offset the scroll of the page on item click if using a sticky nav bar.
+     * @option
+     * @example 25
+     */
+    barOffset: 0
   };
 
   /**
     }).on('click.zf.magellan', 'a[href^="#"]', function(e) {
         e.preventDefault();
         var arrival   = this.getAttribute('href'),
-            scrollPos = $(arrival).offset().top - _this.options.threshold / 2;
+            scrollPos = $(arrival).offset().top - _this.options.threshold / 2 - _this.options.barOffset;
 
         // requestAnimationFrame is disabled for this plugin currently
         // Foundation.Move(_this.options.animationDuration, $body, function(){