0

I need some help with animation with jquery. I have the folowing code:

function getImg(id) {
        var cart = $('#topcartlink');
        var imgtofly = $('#' + id).parents('div.product-item').find('img').eq(0);
        if (imgtofly) {
            var imgclone = imgtofly.clone()
                .attr("id","imageCloneId")
                .offset({ top: imgtofly.offset().top, left: imgtofly.offset().left })
                .css({ 'opacity': '0.7', 'position': 'absolute', 'height': '150px', 'width': '150px', 'z-index': '1000' })
                .appendTo($('body'))
                .animate({
                    'top': cart.offset().top + 10,
                    'left': cart.offset().left + 30,
                    'width': 55,
                    'height': 55
                }, 1000, 'easeInOutExpo');
            imgclone.animate({ 'width': 0, 'height': 0 }, function () { $('#imageCloneId').detach(); });
        }
        return false;
    }

the animation is done correctly except the final part. When the last detach of the clone image isn't done. I have the floating image in my screen and I can't remove it with detach.

Some help here?

Thanks in advance.

user3535054
  • 77
  • 1
  • 11
  • It's unclear exactly what you're trying to do, but try using `remove()` instead of `detach()`. If that doesn't help, could you please set up a working example of the problem in http://jsfiddle.net. Also, just FYI `if (imgtofly)` will *always* be true as `eq()` will always return an object. – Rory McCrossan Mar 06 '15 at 07:38
  • Maybe an example snippet or fiddle would help, seeing your animation and being able to debug working code would help. – Spencer Wieczorek Mar 06 '15 at 07:39
  • I'm trying to do an example in jsfiddle (first time of use), and he told me getImg is not defined when I call this js function. Some help? I'm using also library jquery.easing.1.3.js and jquery.easing.compatibility.1.3.js – user3535054 Mar 06 '15 at 08:48

0 Answers0