Write the necessary JavaScript / Scriptaculous code to complete the skeleton
HTML and JS,
which removes each icon with an Effect.Puff
when it is dragged and
dropped onto the trash can as in
this working solution.
You will first need to inject 20 IE6 icons (imgs of class
.browser
, with a src
of
ie6.png)
into the #browsers div. Use the provided positionRandomly
function to give each img that you inject a random location.
Refer to the Scriptaculous documentation for Draggables, Droppables, and Core Effects to figure out how to configure your objects so that:
.browser
..browser
icon to any part of the page except the trash can results in the icon returning to its original position..browser
element over the trash icon will cause its class to change to .full
.Effect.Puff
when they are dropped onto the trash icon.document.observe('dom:loaded', function() { createBrowsers(); Droppables.add('trashcan', { accept: 'browser', hoverclass: 'full', onDrop: removeBrowser }); }); function createBrowsers() { for (var i = 0; i < 10; i++) { var img = $(document.createElement('img')); img.addClassName('browser'); img.src = 'http://webster.cs.washington.edu/cse190m/sections/9/trashcan/ie6.png'; positionRandomly(img); new Draggable(img, { revert: 'failure' }); $('browsers').appendChild(img); } }
function removeBrowser(elem) { new Effect.Puff(elem, { duration: .5, afterFinish: function() { elem.remove(); } }); }