Permalink
Browse files

When magellan is fixed the threshold is by default the data-magellan-…

…expedition element height

also cached the element into $fixedMagellan
  • Loading branch information...
1 parent 2e7c577 commit d0a8aab5144c1ff185bc55eef0ee3eddee4ab962 @BMCouto committed Oct 29, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 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);

0 comments on commit d0a8aab

Please sign in to comment.