]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Fix scrolling bug when toggling section 1885/head
authorGregory Eremin <magnolia_fan@me.com>
Wed, 13 Mar 2013 21:54:57 +0000 (01:54 +0400)
committerGregory Eremin <magnolia_fan@me.com>
Wed, 13 Mar 2013 21:54:57 +0000 (01:54 +0400)
js/foundation/foundation.section.js

index 2472937cb4362b050bcd29d6d2e8486c7baa5578..b43095064bd016f6567b6ddfa64ec2c5411f2467 100644 (file)
             .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;