Skip to content

Commit 87ef3a2

Browse files
committed
Suggest wrapping Collapse child in no-margin node
It makes a big difference when you have elements with margin or padding; the animation appears much smoother when the contents are enclosed in a node with zero padding and zero margin (like a raw `<div>`). Here are two examples. * with a div: https://cloud.githubusercontent.com/assets/4317806/10871987/4bf4ea48-80ac-11e5-84f5-45c955a22f47.gif * without a div: https://cloud.githubusercontent.com/assets/4317806/10871988/504aee62-80ac-11e5-9232-7dc97c151fef.gif (source: wchargin/lc3@344da3a) The example already wraps its contents in a `<div>`, but it's not clear that or why this is beneficial.
1 parent 3bb42f2 commit 87ef3a2

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

docs/src/ComponentsPage.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,20 @@ const ComponentsPage = React.createClass({
952952

953953
<h3><Anchor id="utilities-collapse">Collapse</Anchor></h3>
954954
<p>Add a collapse toggle animation to an element or component.</p>
955+
<div className="bs-callout bs-callout-info">
956+
<h4>Smoothing animations</h4>
957+
<p>
958+
If you're noticing choppy animations,
959+
and the component that's being collapsed
960+
has non-zero margin or padding,
961+
try wrapping the contents
962+
of your <code>&lt;Collapse&gt;</code>
963+
{" "}inside a node with no margin or padding,
964+
like the <code>&lt;div&gt;</code> in the example below.
965+
This will allow the height to be computed properly,
966+
so the animation can proceed smoothly.
967+
</p>
968+
</div>
955969
<ReactPlayground codeText={Samples.Collapse} />
956970

957971
<h4><Anchor id="utilities-collapse-props">Props</Anchor></h4>

0 commit comments

Comments
 (0)