reverse.mustache revision 3883a992e58e3629e15903ab299e20fce8483e2c
<p>This demonstrates how to use the <code>reverse</code> attribute to change the behavior of the animation.</p>
<p>For this example, we will use <code>Node</code>'s <code>fx</code> plugin to animate the element. The plugin adds the anim instance to the <code>Node</code> instance, pre-configuring it to use the Node instance as the <code>Anim</code>'s node. The <code>plug</code> method accepts a class to construct and an optional config to pass to the constructor.</p>
<p>Setting the <code>from</code> attribute to the expanded height of the element allows us to toggle the effect using the <code>reverse</code> attribute, which we will see below (<code>from</code> uses current value when omitted).</p>
var module = Y.one('#demo');
return node.get('scrollHeight'); // get expanded height (offsetHeight may be zero)
easing: Y.Easing.easeOut,
<p>Because our behavior only works when JS is available, let's go ahead and add our control element using JS as well.</p>
var control = Y.Node.create(
'<a title="show/hide content" class="yui3-toggle">' +
module.one('.yui3-hd').appendChild(control);
<p>Before calling <code>run</code> in our <code>click</code> handler, we will use the <code>reverse</code> attribute toggle the direction of the animation depending on whether its opening or closing.</p>
module.toggleClass('yui-closed');
module.one('.yui3-toggle').on('click', onClick);