From 919f4b0a27c342c5de61c7676b08fb527a6b5e7d Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Thu, 14 Mar 2013 01:54:57 +0400 Subject: [PATCH] Fix scrolling bug when toggling section --- js/foundation/foundation.section.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) 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; -- 2.47.3