src/cm/media/js/lib/yui/yui_3.10.3/docs/transition/index.html
author Yves-Marie Haussonne <ymh.work+github@gmail.com>
Fri, 09 May 2014 18:35:26 +0200
changeset 656 a84519031134
parent 525 89ef5ed3c48b
permissions -rw-r--r--
add link to "privacy policy" in the header test

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Transition</title>
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic">
    <link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
    <script src="../../build/yui/yui-min.js"></script>
    
</head>
<body>
<!--
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
-->
<div id="doc">
    <div id="hd">
        <h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1>
    </div>
    
        <a href="#toc" class="jump">Jump to Table of Contents</a>
    

            <h1>Transition</h1>
    <div class="yui3-g">
        <div class="yui3-u-3-4">
            <div id="main">
                <div class="content">  <div class="intro">
      <p>The Transition Utility provides an API for creating advanced transitions between style property values. Native CSS Transitions are used when possible.</p>
</div>

<h2 id="getting-started">Getting Started</h2>

<p>
To include the source files for Transition and its dependencies, first load
the YUI seed file if you haven't already loaded it.
</p>

<pre class="code prettyprint">&lt;script src=&quot;http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.10.3&#x2F;build&#x2F;yui&#x2F;yui-min.js&quot;&gt;&lt;&#x2F;script&gt;</pre>


<p>
Next, create a new YUI instance for your application and populate it with the
modules you need by specifying them as arguments to the <code>YUI().use()</code> method.
YUI will automatically load any dependencies required by the modules you
specify.
</p>

<pre class="code prettyprint">&lt;script&gt;
&#x2F;&#x2F; Create a new YUI instance and populate it with the required modules.
YUI().use(&#x27;transition&#x27;, function (Y) {
    &#x2F;&#x2F; Transition is available and ready for use. Add implementation
    &#x2F;&#x2F; code here.
});
&lt;&#x2F;script&gt;</pre>


<p>
For more information on creating YUI instances and on the
<a href="http://yuilibrary.com/yui/docs/api/classes/YUI.html#method_use"><code>use()</code> method</a>, see the
documentation for the <a href="../yui/index.html">YUI Global Object</a>.
</p>


				<h2 id="using">Using Transitions</h2>
				<h3 id="attributes">Transition Method</h3>
                    <p>The Transition Utility adds the <code>transition</code> method to <code>Node</code> instances when the <code>transition</code> module is included.  The method accepts a configuration object, and an optional callback function.  The config may include one or more <code>CSS</code> properties to be transitioned, an optional <code>duration</code> (in seconds), <code>delay</code>, and  <code>easing</code> for fine-tuning transition behavior. Calling the <code>transition</code> method begins the transition.  The <code>callback</code> is run after the transition has completed.</p>

<pre class="code prettyprint">Y.one(&#x27;#demo&#x27;).transition({
    easing: &#x27;ease-out&#x27;,
    duration: 0.75, &#x2F;&#x2F; seconds
    width: &#x27;10px&#x27;,
    height: &#x27;10px&#x27;
}, function() {
    this.remove();
});</pre>


				<h3 id="easings">Supported Easings</h3>

                <p>Transition supports the following easings:</p>
                <table>
                <thead>
                    <tr>
                        <th>Easing</th>
                        <th>Description</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>cubic-bezier</code></td>
                        <td>Specifies a cubic-bezier curve. The four values specify points P1 and P2 of the curve as (x1, y1, x2, y2). All values must be in the range [0, 1] or the definition is invalid.</td>
                    </tr>
                    <tr>
                        <td><code>ease (default)</code></td>
                        <td>equivalent to cubic-bezier(0.25, 0.1, 0.25, 1)</td>
                    </tr>
                    <tr>
                        <td><code>linear</code></td>
                        <td>equivalent to cubic-bezier(0, 0, 1, 1)</td>
                    </tr>
                    <tr>
                        <td><code>ease-in</code></td>
                        <td>equivalent to cubic-bezier(0.42, 0, 1, 1)</td>
                    </tr>
                    <tr>
                        <td><code>ease-out</code></td>
                        <td>equivalent to cubic-bezier(0, 0, 0.58, 1)</td>
                    </tr>
                    <tr>
                        <td><code>ease-in-out</code></td>
                        <td>equivalent to cubic-bezier(0.42, 0, 0.58, 1)</td>
                    </tr>
                </tbody>
                </table>
                <p>Transition easings are defined as part of the CSS3 Transition Module.  See the <a href="http://www.w3.org/TR/css3-transitions/#transition-timing-function_tag">full specification</a> for further details.

				<h3 id="attr-specific">Property Specific Attributes</h3>

                    <p>The Transition Utility also allows for property specific attributes.  Each attribute may optionally have its own <code>duration</code>, </code>easing</code>, and/or <code>delay</code>.  This provides much finer control over the transition timeline, enabling more complex effects.</p>

<pre class="code prettyprint">Y.one(&#x27;#demo&#x27;).transition({
    duration: 0.75,
    easing: &#x27;ease-out&#x27;,

    height: 0,

    width: {
        delay: 0.75,
        easing: &#x27;ease-in&#x27;,
        value: 0
    },

    opacity: {
        delay: 1.5,
        duration: 1.25,
        value: 0
    }
});</pre>



        <h3 id="transition-events">Listening for Events</h3>
            <p>The Transition Utility provides optional notifications for reacting to the start and end of a transition.  These can be subscribed to via the <code>on</code> attribute of the transition config.</p>

<pre class="code prettyprint">var node = Y.one(&#x27;#demo&#x27;);

Y.one(&#x27;#demo&#x27;).transition({
    duration: 1,
    height:0,

    width: {
        delay: 1,    
        duration: 0.5,
        value: 0
    },

    on: {
        start: function() {
            Y.log(&#x27;start&#x27;);
        },

        end: function() {
            Y.log(&#x27;end&#x27;);
        }
    }
});</pre>


        <p>For simplicity, an end handler can also be added as a function callback:

<pre class="code prettyprint">Y.one(&#x27;#demo&#x27;).transition({
    duration: 1,
    height:0,

    width: {
        delay: 1,    
        duration: 0.5,
        value: 0
    }
}, function() {
    Y.log(&#x27;end&#x27;);
});</pre>

</div>
            </div>
        </div>

        <div class="yui3-u-1-4">
            <div class="sidebar">
                
                    <div id="toc" class="sidebox">
                        <div class="hd">
                            <h2 class="no-toc">Table of Contents</h2>
                        </div>

                        <div class="bd">
                            <ul class="toc">
<li>
<a href="#getting-started">Getting Started</a>
</li>
<li>
<a href="#using">Using Transitions</a>
<ul class="toc">
<li>
<a href="#attributes">Transition Method</a>
</li>
<li>
<a href="#easings">Supported Easings</a>
</li>
<li>
<a href="#attr-specific">Property Specific Attributes</a>
</li>
<li>
<a href="#transition-events">Listening for Events</a>
</li>
</ul>
</li>
</ul>
                        </div>
                    </div>
                

                
                    <div class="sidebox">
                        <div class="hd">
                            <h2 class="no-toc">Examples</h2>
                        </div>

                        <div class="bd">
                            <ul class="examples">
                                
                                    
                                        <li data-description="Demonstrates the basic usage of Transitions.">
                                            <a href="transition-basic.html">Basic Node Transitions</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Demonstrates more advanced usage of Transitions.">
                                            <a href="transition-usage.html">Using Transitions</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Demonstrates how to animate Node&#x27;s show and hide methods.">
                                            <a href="transition-view.html">Showing and Hiding with Transitions</a>
                                        </li>
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                            </ul>
                        </div>
                    </div>
                

                
                    <div class="sidebox">
                        <div class="hd">
                            <h2 class="no-toc">Examples That Use This Component</h2>
                        </div>

                        <div class="bd">
                            <ul class="examples">
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                        <li data-description="Shows how to create a panel that animates as it is shown and hidden">
                                            <a href="../panel/panel-animate.html">Creating an Animated Panel</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="This example employs AsyncQueue to incrementally construct an application interface; this illustrates the approach you&#x27;d take to allow chunked rendering of the UI in a process-intensive application.">
                                            <a href="../async-queue/queue-app.html">Building a UI with AsyncQueue</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Extend the Promise class to create your own Node plugin that chains transitions">
                                            <a href="../promise/plugin-example.html">Creating a Node Plugin that chains transitions</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Create a reusable JSONPRequest object to poll the YUILibrary.com Gallery web service, fetching info on a random Gallery module.">
                                            <a href="../jsonp/jsonp-gallery.html">Reusing a JSONPRequest Instance to Poll a Remote Server</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="NodeList provides Node functionality for manipulating multiple nodes at once.">
                                            <a href="../node/nodelist.html">Using NodeList - Simple</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="How to use multiple NodeList features to build a simple game.">
                                            <a href="../node/ducks.html">Using NodeList - Ducks Game</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="This example demonstrates how to insert content into a Node.">
                                            <a href="../node/node-insert.html">Adding Node Content - Burger Builder</a>
                                        </li>
                                    
                                
                            </ul>
                        </div>
                    </div>
                
            </div>
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

<script>
YUI.Env.Tests = {
    examples: [],
    project: '../assets',
    assets: '../assets/transition',
    name: 'transition',
    title: 'Transition',
    newWindow: '',
    auto:  false 
};
YUI.Env.Tests.examples.push('transition-basic');
YUI.Env.Tests.examples.push('transition-usage');
YUI.Env.Tests.examples.push('transition-view');
YUI.Env.Tests.examples.push('panel-animate');
YUI.Env.Tests.examples.push('queue-app');
YUI.Env.Tests.examples.push('plugin-example');
YUI.Env.Tests.examples.push('jsonp-gallery');
YUI.Env.Tests.examples.push('nodelist');
YUI.Env.Tests.examples.push('ducks');
YUI.Env.Tests.examples.push('node-insert');

</script>
<script src="../assets/yui/test-runner.js"></script>



</body>
</html>