YUI 3.x Home -

YUI Library Examples: Drag & Drop: Animated Drop Targets

Note: This is YUI 3.x. Looking for YUI 2.x?

Drag & Drop: Animated Drop Targets

This example will show you how to make an animated node a Drop target.

Setting up the HTML

First we will create our HTML.

Now we give that HTML some CSS to make it visible.

Setting up the YUI Instance

Now we need to create our YUI instance and tell it to load the dd-drop, dd-plugin, dd-drop-plugin and anim modules.

Making the Node draggable

Now that we have a YUI instance with the modules loaded, we need to instantiate the Drag instance on this Node.

In this example we will be using Node plugins to accomplish our tasks.

Animating the Nodes

Now we will setup the Animation sequence that we want to run.

Making the Node A Target

Using the dd-drop-plugin, we now need to make this animated Node a Drop Target.

To do that, we need to add the plugin after the fx plugin.

Syncing the Target with the Animation

The Drop Target needs to be in sync with the animation, since we are changing the height, width, top and left style.

We do this by adding a listener to the tween event on the animation instance.

Full example source

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings