Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explode animation with jquery

I have a container with a span tag and if I click the span element I need to have a explode animaton and remove that element.

I am able to use fade effect but I am not sure how to use explode effect as If use this way it is just deleting without any animation:

Css:

#container a span { display:none; background-image:url(images/remove.png); background-repeat:no-repeat; width:16px; height:16px; position:absolute; right:0px; top:0px;} 
#container a:hover span { display:block;}  

Fade Effect:

  $('.container a span').live('click', function (e) {
                $(this).closest('div.container').fadeOut("normal", function () {
                  $(this).remove();
                                });
                return false;
   });

Explode Effect

$('.container a span').live('click', function (e) {
                    $(this).closest('div.container').fadeOut("normal", function () {
                    $(this).hide('explode', { pieces: 25 }, 600);
                      $(this).remove();
                                    });
                    return false;
});

These are the images which are added dynamically where I am binding as follows:

 uploader.bind('FileUploaded', function (up, file, res) {
            $('#container').append("<div class='container a'><a href='#'><img src='uploads/" + document.getElementById("currentDirectory").value + "/" + file.name + "' width='64' height='64'/><span></span></a></div>");

            $('.container a span').live('click', function (e) {
                $(this).closest('div.container').fadeOut("normal", function () {
                    $(this).remove();
                });
                return false;
            });
});

This is where I am showing the Images:

 <div id="container">

  </div>
like image 900
coder Avatar asked May 12 '26 11:05

coder


1 Answers

I think this is what you want?

$('.container a span').live('click', function (e) {
    $(this).hide('explode', { "pieces":25 }, 600, function() { $(this).remove; });
    return false;
});
like image 113
Jeff Ancel Avatar answered May 14 '26 01:05

Jeff Ancel