Trigger cart animation

johnohod
Offline
Last seen: 1 year 7 months ago
Sat, 10/07/2017 - 23:09
#1
Trigger cart animation

I would like to trigger the shopping cart animation (same as on mouseover) whenever somebody put someting in the cart. What javascript function can I use?

cindy
cindy's picture
Offline
Last seen: 2 weeks 5 days ago
Mon, 10/09/2017 - 11:53

Hi,

You can check the following code, which we use in our Wordpress theme version of Mojado 

$body.on('adding_to_cart', function(e, $button) {
var $product = $button.parents('.product-grid');
var $imgDrag = getProductImage($product);

if ($imgDrag) {
var $imgClone = $imgDrag.clone();

$imgClone.offset({
top: $imgDrag.offset().top,
left: $imgDrag.offset().left
});

$imgClone.css({
'opacity': '0.75',
'position': 'absolute',
'height': '150px',
'width': '150px',
'z-index': '999999'
});

$imgClone.appendTo($body);

$imgClone.animate({
'top': $cart.offset().top + 10,
'left': $cart.offset().left + 10,
'width': 75,
'height': 75
}, 1000);

$imgClone.animate({
'width': 0,
'height': 0
}, function () {
$(this).detach();
});
}
});
Log in or register to post comments