/* Add to cart fly effect with jQuery. - May 05, 2013 (c) 2013 @ElmahdiMahmoud - fikra-masri.by license: https://www.opensource.org/licenses/mit-license.php */ $('.add-to-cart').on('click', function () { var cart = $('.shopping-cart'); var imgtodrag = $(this).parent('.cartitem').find("img").eq(0); if (imgtodrag) { var imgclone = imgtodrag.clone() .offset({ top: imgtodrag.offset().top, left: imgtodrag.offset().left }) .css({ 'opacity': '0.8', 'position': 'absolute', 'height': '80px', 'width': '80px', 'z-index': '0' }) .appendTo($('body')) .animate({ 'top': cart.offset().top + 10, 'left': cart.offset().left + 10, 'width': 75, 'height': 75 }, 2000, 'easeInOutExpo'); imgclone.animate({ 'width': 0, 'height': 0 }, function () { $(this).detach() }); } });