From 66606407edf9faa33c566f0cc6a2bb1dd4d3e808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 14 Jan 2011 14:35:37 -0500 Subject: [PATCH] Accordion: Force the width of the accordion panel during animation when animating from a fully collapsed state. Fixes #5540 - Accordion: Jumpy animation when opening a panel after closing all. The animation code should be refactored. --- demos/accordion/default.html | 93 +++++++++++------------------------- ui/jquery.ui.accordion.js | 34 ++++++++----- 2 files changed, 50 insertions(+), 77 deletions(-) diff --git a/demos/accordion/default.html b/demos/accordion/default.html index 974dc0569..c2774c549 100644 --- a/demos/accordion/default.html +++ b/demos/accordion/default.html @@ -4,82 +4,43 @@ jQuery UI Accordion - Default functionality - + + -
- -
-

Section 1

-
-

- Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer - ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit - amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut - odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate. -

+
+

Header

+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus eleifend odio. Suspendisse porta pretium urna, vitae euismod turpis pharetra elementum. Donec malesuada laoreet est vel bibendum. Donec tempus, urna sit amet consequat molestie, sapien tellus pellentesque lectus, consectetur volutpat urna dolor eget elit. Donec tempus feugiat nulla in egestas. Duis eleifend sollicitudin lobortis. Vivamus ornare, ipsum et laoreet blandit, tortor nulla congue justo, ac eleifend massa neque ac eros. Nullam condimentum, nibh sed rutrum faucibus, velit metus malesuada est, lacinia vulputate ante nibh ut massa. Quisque et elementum nulla. Mauris a sem in odio cursus varius in nec ante. Vestibulum accumsan massa et dolor tincidunt ac laoreet massa imperdiet. Mauris eleifend turpis non sapien accumsan egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+
+

Header

+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus eleifend odio. Suspendisse porta pretium urna, vitae euismod turpis pharetra elementum. Donec malesuada laoreet est vel bibendum. Donec tempus, urna sit amet consequat molestie, sapien tellus pellentesque lectus, consectetur volutpat urna dolor eget elit. Donec tempus feugiat nulla in egestas. Duis eleifend sollicitudin lobortis. Vivamus ornare, ipsum et laoreet blandit, tortor nulla congue justo, ac eleifend massa neque ac eros. Nullam condimentum, nibh sed rutrum faucibus, velit metus malesuada est, lacinia vulputate ante nibh ut massa. Quisque et elementum nulla. Mauris a sem in odio cursus varius in nec ante. Vestibulum accumsan massa et dolor tincidunt ac laoreet massa imperdiet. Mauris eleifend turpis non sapien accumsan egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+
+

Header

+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus eleifend odio. Suspendisse porta pretium urna, vitae euismod turpis pharetra elementum. Donec malesuada laoreet est vel bibendum. Donec tempus, urna sit amet consequat molestie, sapien tellus pellentesque lectus, consectetur volutpat urna dolor eget elit. Donec tempus feugiat nulla in egestas. Duis eleifend sollicitudin lobortis. Vivamus ornare, ipsum et laoreet blandit, tortor nulla congue justo, ac eleifend massa neque ac eros. Nullam condimentum, nibh sed rutrum faucibus, velit metus malesuada est, lacinia vulputate ante nibh ut massa. Quisque et elementum nulla. Mauris a sem in odio cursus varius in nec ante. Vestibulum accumsan massa et dolor tincidunt ac laoreet massa imperdiet. Mauris eleifend turpis non sapien accumsan egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+
-

Section 2

-
-

- Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet - purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor - velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In - suscipit faucibus urna. -

-
-

Section 3

-
-

- Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. - Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero - ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis - lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. -

-
    -
  • List item one
  • -
  • List item two
  • -
  • List item three
  • -
-
-

Section 4

-
-

- Cras dictum. Pellentesque habitant morbi tristique senectus et netus - et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in - faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia - mauris vel est. -

-

- Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. - Class aptent taciti sociosqu ad litora torquent per conubia nostra, per - inceptos himenaeos. -

-
-
- -
- -
-

-Click headers to expand/collapse content that is broken into logical sections, much like tabs. -Optionally, toggle sections open/closed on mouseover. -

-

-The underlying HTML markup is a series of headers (H3 tags) and content divs so the content is -usable without JavaScript. -

-
- diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 098ca4090..a31abd198 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -499,16 +499,34 @@ $.extend( $.ui.accordion, { version: "@VERSION", animations: { slide: function( options, additions ) { + var overflow = options.toShow.css( "overflow" ), + percentDone = 0, + showProps = {}, + hideProps = {}, + fxAttrs = [ "height", "paddingTop", "paddingBottom" ], + originalWidth; options = $.extend({ easing: "swing", duration: 300 }, options, additions ); if ( !options.toHide.size() ) { - options.toShow.animate({ - height: "show", - paddingTop: "show", - paddingBottom: "show" - }, options ); + originalWidth = options.toShow[0].style.width; + options.toShow + .show() + .width( options.toShow.width() ) + .hide() + .animate({ + height: "show", + paddingTop: "show", + paddingBottom: "show" + }, { + duration: options.duration, + easing: options.easing, + complete: function() { + options.toShow.width( originalWidth ); + options.complete(); + } + }); return; } if ( !options.toShow.size() ) { @@ -519,12 +537,6 @@ $.extend( $.ui.accordion, { }, options ); return; } - var overflow = options.toShow.css( "overflow" ), - percentDone = 0, - showProps = {}, - hideProps = {}, - fxAttrs = [ "height", "paddingTop", "paddingBottom" ], - originalWidth; // fix width before calculating height of hidden element var s = options.toShow; originalWidth = s[0].style.width;