js/foundation/foundation.topbar.js in zurb-foundation-4.2.2 vs js/foundation/foundation.topbar.js in zurb-foundation-4.2.3

- old
+ new

@@ -4,11 +4,11 @@ 'use strict'; Foundation.libs.topbar = { name : 'topbar', - version : '4.2.2', + version : '4.2.3', settings : { index : 0, stickyClass : 'sticky', custom_back_text: true, @@ -84,11 +84,11 @@ section.find('li.moved').removeClass('moved'); topbar.data('index', 0); topbar .toggleClass('expanded') - .css('max-height', ''); + .css('height', ''); } if (!topbar.hasClass('expanded')) { if (topbar.hasClass('fixed')) { topbar.parent().addClass('fixed'); @@ -162,18 +162,18 @@ } else { section.css({right: -(100 * topbar.data('index')) + '%'}); section.find('>.name').css({right: 100 * topbar.data('index') + '%'}); } - topbar.css('max-height', self.height($this.siblings('ul')) + self.outerHeight(titlebar, true)); + topbar.css('height', self.outerHeight($this.siblings('ul'), true) + self.outerHeight(titlebar, true)); } }); $(window).on('resize.fndtn.topbar', function () { if (!self.breakpoint()) { $('.top-bar, [data-topbar]') - .css('max-height', '') + .css('height', '') .removeClass('expanded') .find('li') .removeClass('hover'); } }.bind(this)); @@ -208,13 +208,13 @@ section.css({right: -(100 * topbar.data('index')) + '%'}); section.find('>.name').css({right: 100 * topbar.data('index') + '%'}); } if (topbar.data('index') === 0) { - topbar.css('max-height', ''); + topbar.css('height', ''); } else { - topbar.css('max-height', self.height($previousLevelUl) + self.outerHeight(titlebar, true)); + topbar.css('height', self.outerHeight($previousLevelUl, true) + self.outerHeight(titlebar, true)); } setTimeout(function () { $movedLi.removeClass('moved'); }, 300); @@ -270,17 +270,23 @@ var klass = '.' + this.settings.stickyClass; if ($(klass).length > 0) { var distance = $(klass).length ? $(klass).offset().top: 0, $window = $(window); var offst = this.outerHeight($('.top-bar')); - + //Whe resize elements of the page on windows resize. Must recalculate distance + $(window).resize(function() { + clearTimeout(t_top); + t_top = setTimeout (function() { + distance = $(klass).offset().top; + },105); + }); $window.scroll(function() { - if ($window.scrollTop() >= (distance)) { + if ($window.scrollTop() > (distance)) { $(klass).addClass("fixed"); $('body').css('padding-top',offst); } - else if ($window.scrollTop() < distance) { + else if ($window.scrollTop() <= distance) { $(klass).removeClass("fixed"); $('body').css('padding-top','0'); } }); }