]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
When magellan is fixed the threshold is by default the data-magellan-expedition eleme... 1087/head
authorBMCouto <bmcouto@gmail.com>
Mon, 29 Oct 2012 23:45:11 +0000 (23:45 +0000)
committerBMCouto <bmcouto@gmail.com>
Mon, 29 Oct 2012 23:45:11 +0000 (23:45 +0000)
also cached the element into $fixedMagellan

vendor/assets/javascripts/foundation/jquery.foundation.magellan.js

index f816ae3adbad9c168fa8c6547846bdc331403fb6..1d4783a71a194c013ff7b095517fad8021595452 100644 (file)
@@ -12,8 +12,9 @@
   'use strict';
 
   $.fn.foundationMagellan = function(options) {
-    var defaults = {
-      threshold: 25,
+    var $fixedMagellan = $('[data-magellan-expedition=fixed]'),
+       defaults = {
+      threshold: ($fixedMagellan.length) ? $fixedMagellan.outerHeight(true) : 25,
       activeClass: 'active'
     },
 
       .addClass($expedition.attr('data-magellan-active-class') || options.activeClass);
 
     // Update fixed position
-    $('[data-magellan-expedition=fixed]').on('magellan.update-position', function(){
+    $fixedMagellan.on('magellan.update-position', function(){
       var $el = $(this);
       $el.data("magellan-fixed-position","");
       $el.data("magellan-top-offset", "");
     });
 
-    $('[data-magellan-expedition=fixed]').trigger('magellan.update-position');
+    $fixedMagellan.trigger('magellan.update-position');
 
     $(window).on('resize.magellan', function() {
-      $('[data-magellan-expedition=fixed]').trigger('magellan.update-position');
+      $fixedMagellan.trigger('magellan.update-position');
     });
     
     $(window).on('scroll.magellan', function() {
       var windowScrollTop = $(window).scrollTop();
-      $('[data-magellan-expedition=fixed]').each(function() {
+      $fixedMagellan.each(function() {
         var $expedition = $(this);
         if ($expedition.data("magellan-top-offset") === "") {
           $expedition.data("magellan-top-offset", $expedition.offset().top);