From d0a8aab5144c1ff185bc55eef0ee3eddee4ab962 Mon Sep 17 00:00:00 2001 From: BMCouto Date: Mon, 29 Oct 2012 23:45:11 +0000 Subject: [PATCH] When magellan is fixed the threshold is by default the data-magellan-expedition element height also cached the element into $fixedMagellan --- .../foundation/jquery.foundation.magellan.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/vendor/assets/javascripts/foundation/jquery.foundation.magellan.js b/vendor/assets/javascripts/foundation/jquery.foundation.magellan.js index f816ae3ad..1d4783a71 100644 --- a/vendor/assets/javascripts/foundation/jquery.foundation.magellan.js +++ b/vendor/assets/javascripts/foundation/jquery.foundation.magellan.js @@ -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' }, @@ -37,21 +38,21 @@ .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); -- 2.47.3