src/cm/media/js/lib/yui/yui3.0.0/examples/anim/curve_clean.html
author Yves-Marie Haussonne <ymh.work+github@gmail.com>
Fri, 09 May 2014 18:35:26 +0200
changeset 656 a84519031134
parent 0 40c8f766c9b8
permissions -rw-r--r--
add link to "privacy policy" in the header test


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Animating Along a Curved Path</title>

<style type="text/css">
/*margin and padding on body element
  can introduce errors in determining
  element position and are not recommended;
  we turn them off as a foundation for YUI
  CSS treatments. */
body {
	margin:0;
	padding:0;
}
</style>

<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
<script type="text/javascript" src="../../build/yui/yui-min.js"></script>


<!--begin custom header content for this example-->
<link href="assets//anim.css" rel="stylesheet" type="text/css">

<!--end custom header content for this example-->

</head>

<body class=" yui-skin-sam">

<h1>Animating Along a Curved Path</h1>

<div class="exampleIntro">
	<p>This demonstrates how to animate the position of an element along a <code>curve</code>.</p>
<p> Click anywhere to move the element to your click position.</p>
			
</div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<span id="demo"></span>

<script type="text/javascript">
YUI({base:"../../build/", timeout: 10000}).use("anim", function(Y) {
    var node = Y.get('#demo');

    var anim = new Y.Anim({
        node: node,
        duration: 1.5,
        easing: Y.Easing.easeOut
    });

    var randomCurve = function(end) {
        var points = [],
            n = 3,
            winWidth = node.get('winWidth'),
            winHeight = node.get('winHeight');

        for (var i = 0; i < n; ++i) {
            points.push([
                Math.floor(Math.random() * winWidth),
                Math.floor(Math.random() * winHeight)
            ]);
        }

        if (end) {
            points.push(end);
        }
        return points;
    };

    var onClick = function(e) {
        anim.set('to', {
            curve: randomCurve([e.pageX, e.pageY])
        });
        anim.run();
    };
    
    Y.get('document').on('click', onClick);

});

</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

</body>
</html>