5
<title>Example: Showing and Hiding with Transitions</title>
6
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
7
<link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
8
<link rel="stylesheet" href="../assets/css/main.css">
9
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
10
<script src="../../build/yui/yui-min.js"></script>
15
<h1>Example: Showing and Hiding with Transitions</h1>
20
<div class="yui3-u-3-4">
22
<div class="content"><style scoped>
26
background-color: #B6BFDA;
27
border: 1px solid #7E869D;
28
box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.25);
38
<p>This example shows how to show and hide Node instances.</p>
42
<button id="hide">hide</button>
43
<button id="show">show</button>
45
<div class="demo"><p>lorem ipsum dolor sit</p></div>
47
<script type="text/javascript">
48
YUI().use('transition', 'node-event-delegate', function(Y) {
49
Y.delegate('click', function(e) {
50
var buttonID = e.currentTarget.get('id'),
51
node = Y.one('.demo');
53
if (buttonID === 'show') {
55
} else if (buttonID == 'hide') {
59
}, document, 'button');
65
<h2>Showing a Node</h2>
66
<p>The view of a Node instance can be transitioned by passing <code>true</code> to the <code>show</code> and <code>hide</code> methods.</p>
68
<pre class="code prettyprint">Y.one('.demo').show(true);</pre>
71
<h2>Hiding a Node</h2>
72
<p>The opposite of <code>show</code>, the <code>hide</code> method sets the node's CSS <code>display</code> property to <code>none</code>.</p>
74
<pre class="code prettyprint">Y.one('.demo').hide(true);</pre>
77
<h2>Complete Example Source</h2>
78
<pre class="code prettyprint"><button id="hide">hide</button>
79
<button id="show">show</button>
81
<div class="demo"><p>lorem ipsum dolor sit</p></div>
83
<script type="text/javascript">
84
YUI().use('transition', 'node-event-delegate', function(Y) {
85
Y.delegate('click', function(e) {
86
var buttonID = e.currentTarget.get('id'),
87
node = Y.one('.demo');
89
if (buttonID === 'show') {
91
} else if (buttonID == 'hide') {
95
}, document, 'button');
97
</script></pre>
103
<div class="yui3-u-1-4">
104
<div class="sidebar">
108
<div class="sidebox">
110
<h2 class="no-toc">Examples</h2>
114
<ul class="examples">
117
<li data-description="Demonstrates the basic usage of Transitions.">
118
<a href="transition-basic.html">Basic Node Transitions</a>
123
<li data-description="Demonstrates more advanced usage of Transitions.">
124
<a href="transition-usage.html">Using Transitions</a>
129
<li data-description="Demonstrates how to animate Node's show and hide methods.">
130
<a href="transition-view.html">Showing and Hiding with Transitions</a>
150
<div class="sidebox">
152
<h2 class="no-toc">Examples That Use This Component</h2>
156
<ul class="examples">
165
<li data-description="Shows how to create a panel that animates as it is shown and hidden">
166
<a href="../panel/panel-animate.html">Creating an Animated Panel</a>
171
<li data-description="NodeList provides Node functionality for manipulating multiple nodes at once.">
172
<a href="../node/nodelist.html">Using NodeList - Simple</a>
177
<li data-description="How to use multiple NodeList features to build a simple game.">
178
<a href="../node/ducks.html">Using NodeList - Ducks Game</a>
183
<li data-description="This example employs AsyncQueue to incrementally construct an application interface; this illustrates the approach you'd take to allow chunked rendering of the UI in a process-intensive application.">
184
<a href="../async-queue/queue-app.html">Building a UI with AsyncQueue</a>
189
<li data-description="Create a reusable JSONPRequest object to poll the YUILibrary.com Gallery web service, fetching info on a random Gallery module.">
190
<a href="../jsonp/jsonp-gallery.html">Reusing a JSONPRequest Instance to Poll a Remote Server</a>
203
<script src="../assets/vendor/prettify/prettify-min.js"></script>
204
<script>prettyPrint();</script>