small medium large xlarge

Generic-user-small
11 Apr 2017, 10:31
Francesco mari (4 posts)

Hi! I wanted to share a nice jquery effect to have when showing the cart the first time we add something to the cart!

This is the final result:

https://www.youtube.com/watch?v=a8kgT2iaNH0

And this is create.js.erb:

if ($('#cart tr').length == 1){
  need_to_show_cart = true;
}

$('#cart').html("<%= j render(@cart) %>").promise().done(function(){
  if (need_to_show_cart) {
    $('#cart').css('opacity', 0).slideDown(600).promise().done(function(){
      this.animate({ opacity: 1 },{ queue: false, duration: 600 });
      need_to_show_cart = false;
    });
  }
});

Suggestions are always welcome!

You must be logged in to comment