mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
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.
This commit is contained in:
parent
1b2f6ce095
commit
66606407ed
@ -4,82 +4,43 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>jQuery UI Accordion - Default functionality</title>
|
<title>jQuery UI Accordion - Default functionality</title>
|
||||||
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
|
<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.core.js"></script>
|
||||||
<script src="../../ui/jquery.ui.widget.js"></script>
|
<script src="../../ui/jquery.ui.widget.js"></script>
|
||||||
<script src="../../ui/jquery.ui.accordion.js"></script>
|
<script src="../../ui/jquery.ui.accordion.js"></script>
|
||||||
<link rel="stylesheet" href="../demos.css">
|
<link rel="stylesheet" href="../demos.css">
|
||||||
|
<style type="text/css">
|
||||||
|
#accordion {
|
||||||
|
width: 600px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function(){
|
||||||
$( "#accordion" ).accordion();
|
|
||||||
|
$("#accordion").accordion({
|
||||||
|
autoHeight: false,
|
||||||
|
active: false,
|
||||||
|
collapsible: true
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="demo">
|
<div id="accordion">
|
||||||
|
<h3><a href="#section1">Header</a></h3>
|
||||||
<div id="accordion">
|
|
||||||
<h3><a href="#">Section 1</a></h3>
|
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<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>
|
||||||
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>
|
</div>
|
||||||
<h3><a href="#">Section 2</a></h3>
|
<h3><a href="#section1">Header</a></h3>
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<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>
|
||||||
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>
|
</div>
|
||||||
<h3><a href="#">Section 3</a></h3>
|
<h3><a href="#section1">Header</a></h3>
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<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>
|
||||||
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>
|
</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>
|
|
||||||
|
|
||||||
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
28
ui/jquery.ui.accordion.js
vendored
28
ui/jquery.ui.accordion.js
vendored
@ -499,16 +499,34 @@ $.extend( $.ui.accordion, {
|
|||||||
version: "@VERSION",
|
version: "@VERSION",
|
||||||
animations: {
|
animations: {
|
||||||
slide: function( options, additions ) {
|
slide: function( options, additions ) {
|
||||||
|
var overflow = options.toShow.css( "overflow" ),
|
||||||
|
percentDone = 0,
|
||||||
|
showProps = {},
|
||||||
|
hideProps = {},
|
||||||
|
fxAttrs = [ "height", "paddingTop", "paddingBottom" ],
|
||||||
|
originalWidth;
|
||||||
options = $.extend({
|
options = $.extend({
|
||||||
easing: "swing",
|
easing: "swing",
|
||||||
duration: 300
|
duration: 300
|
||||||
}, options, additions );
|
}, options, additions );
|
||||||
if ( !options.toHide.size() ) {
|
if ( !options.toHide.size() ) {
|
||||||
options.toShow.animate({
|
originalWidth = options.toShow[0].style.width;
|
||||||
|
options.toShow
|
||||||
|
.show()
|
||||||
|
.width( options.toShow.width() )
|
||||||
|
.hide()
|
||||||
|
.animate({
|
||||||
height: "show",
|
height: "show",
|
||||||
paddingTop: "show",
|
paddingTop: "show",
|
||||||
paddingBottom: "show"
|
paddingBottom: "show"
|
||||||
}, options );
|
}, {
|
||||||
|
duration: options.duration,
|
||||||
|
easing: options.easing,
|
||||||
|
complete: function() {
|
||||||
|
options.toShow.width( originalWidth );
|
||||||
|
options.complete();
|
||||||
|
}
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( !options.toShow.size() ) {
|
if ( !options.toShow.size() ) {
|
||||||
@ -519,12 +537,6 @@ $.extend( $.ui.accordion, {
|
|||||||
}, options );
|
}, options );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var overflow = options.toShow.css( "overflow" ),
|
|
||||||
percentDone = 0,
|
|
||||||
showProps = {},
|
|
||||||
hideProps = {},
|
|
||||||
fxAttrs = [ "height", "paddingTop", "paddingBottom" ],
|
|
||||||
originalWidth;
|
|
||||||
// fix width before calculating height of hidden element
|
// fix width before calculating height of hidden element
|
||||||
var s = options.toShow;
|
var s = options.toShow;
|
||||||
originalWidth = s[0].style.width;
|
originalWidth = s[0].style.width;
|
||||||
|
Loading…
Reference in New Issue
Block a user