<link href="{{componentAssets}}/anim.css" rel="stylesheet" type="text/css">
<div class="intro">
    <p>This demonstrates how to animate the <code>xy</code> position of an element.</p>
    <p>Click anywhere on the gray box below and the little orange box will move to the click position.</p>
</div>

<div class="example">
{{>anim-xy-source}}
</div>

<h3>Setting up the HTML</h3>
<p>First we add some HTML to animate.</p>

```
<div id="demo-stage">
    <span id="demo"></span>
</div>
```

<h3>Creating the Anim Instance</h3>
<p>Now we create an instance of <code>Y.Anim</code>, passing it a configuration object that includes the <code>node</code> we wish to animate. We will set the <code>to</code> attribute later when then animation runs.</p>

```
var anim = new Y.Anim({
    node: '#demo',
    duration: 0.5,
    easing: Y.Easing.elasticOut
});
```

<h3>Changing Attributes</h3>
<p>Next we need a <code>click</code> handler to set the <code>to</code> attribute for the <code>xy</code> behavior and run the animation.</p>

```
var onClick = function(e) {
    anim.set('to', { xy: [e.pageX, e.pageY] });
    anim.run();
};
```

<h3>Running the Animation</h3>
<p>Finally we add an event handler to run the animation when the document is clicked.</p>

```
Y.one('document').on('click', onClick);
```

<h2>Complete Example Source</h2>
```
{{>anim-xy-source}}
```
