From: Gregory Eremin Date: Wed, 13 Mar 2013 21:54:57 +0000 (+0400) Subject: Fix scrolling bug when toggling section X-Git-Tag: v4.0.6~16^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=919f4b0a27c342c5de61c7676b08fb527a6b5e7d;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Fix scrolling bug when toggling section --- diff --git a/js/foundation/foundation.section.js b/js/foundation/foundation.section.js index 2472937cb..b43095064 100644 --- a/js/foundation/foundation.section.js +++ b/js/foundation/foundation.section.js @@ -83,26 +83,29 @@ .attr('style', ''); } } else { + var prev_active_section = null, + title_height = self.outerHeight(section.find('.title')); + if (self.small(parent) || self.settings.one_up) { - $this - .closest('[data-section]') - .find('section, .section') - .removeClass('active') - .attr('style', ''); + prev_active_section = $this.closest('[data-section]').find('section.active, .section.active'); - section.css('padding-top', self.outerHeight(section.find('.title'))); + if (self.small(parent)) { + prev_active_section.attr('style', ''); + } else { + prev_active_section.attr('style', 'visibility: hidden; padding-top: '+title_height+'px;'); + } } - $('[data-section].vertical-nav, [data-section].horizontal-nav') - .find('section, .section') - .removeClass('active') - .attr('style', ''); - if (self.small(parent)) { section.attr('style', ''); + } else { + section.css('padding-top', title_height); } section.addClass('active'); + if (prev_active_section !== null) { + prev_active_section.removeClass('active').attr('style', ''); + } } setTimeout(function () { self.settings.toggled = false;