Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Accordion: Force the width of the accordion panel during animation wh…

…en animating from a fully collapsed state. Fixes #5540 - Accordion: Jumpy animation when opening a panel after closing all.

The animation code should be refactored.
  • Loading branch information...
commit 66606407edf9faa33c566f0cc6a2bb1dd4d3e808 1 parent 1b2f6ce
@scottgonzalez scottgonzalez authored
Showing with 50 additions and 77 deletions.
  1. +27 −66 demos/accordion/default.html
  2. +23 −11 ui/jquery.ui.accordion.js
View
93 demos/accordion/default.html
@@ -4,82 +4,43 @@
<meta charset="utf-8">
<title>jQuery UI Accordion - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
- <script src="../../jquery-1.4.4.js"></script>
+ <script src="http://code.jquery.com/jquery-git.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.accordion.js"></script>
<link rel="stylesheet" href="../demos.css">
+ <style type="text/css">
+#accordion {
+ width: 600px;
+}
+</style>
<script>
- $(function() {
- $( "#accordion" ).accordion();
+ $(function(){
+
+ $("#accordion").accordion({
+ autoHeight: false,
+ active: false,
+ collapsible: true
+ });
+
});
</script>
</head>
<body>
-<div class="demo">
-
-<div id="accordion">
- <h3><a href="#">Section 1</a></h3>
- <div>
- <p>
- 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.
- </p>
- </div>
- <h3><a href="#">Section 2</a></h3>
- <div>
- <p>
- 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.
- </p>
- </div>
- <h3><a href="#">Section 3</a></h3>
- <div>
- <p>
- 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.
- </p>
- <ul>
- <li>List item one</li>
- <li>List item two</li>
- <li>List item three</li>
- </ul>
+ <div id="accordion">
+ <h3><a href="#section1">Header</a></h3>
+ <div>
+ <p>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.</p>
+ </div>
+ <h3><a href="#section1">Header</a></h3>
+ <div>
+ <p>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.</p>
+ </div>
+ <h3><a href="#section1">Header</a></h3>
+ <div>
+ <p>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.</p>
+ </div>
</div>
- <h3><a href="#">Section 4</a></h3>
- <div>
- <p>
- 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.
- </p>
- <p>
- Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
- Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
- inceptos himenaeos.
- </p>
- </div>
-</div>
-
-</div><!-- End demo -->
-
-<div class="demo-description">
-<p>
-Click headers to expand/collapse content that is broken into logical sections, much like tabs.
-Optionally, toggle sections open/closed on mouseover.
-</p>
-<p>
-The underlying HTML markup is a series of headers (H3 tags) and content divs so the content is
-usable without JavaScript.
-</p>
-</div><!-- End demo-description -->
-
</body>
</html>
View
34 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;
Please sign in to comment.
Something went wrong with that request. Please try again.