[IMP] website_sale: increase cart quantity after animation

After this commit, the cart quantity (in the navbar) increase after
the animation instead of before the animation.

We also changed the animation of the cart quantity to have a small
zoom when the number changes instead of an hide followed by a fade in.

task-2574300

PR-73234
This commit is contained in:
Benjamin Vray
2021-08-03 14:10:58 +00:00
committed by Jeremy Kersten
parent 39cb65f79a
commit 6aaf9b6c0e
4 changed files with 13 additions and 5 deletions
@@ -324,7 +324,7 @@ publicWidget.registry.WebsiteSale = publicWidget.Widget.extend(VariantMixin, car
}
wSaleUtils.updateCartNavBar(data);
$input.val(data.quantity);
$('.js_quantity[data-line-id='+line_id+']').val(data.quantity).html(data.quantity);
$('.js_quantity[data-line-id='+line_id+']').val(data.quantity).text(data.quantity);
if (data.warning) {
var cart_alert = $('.oe_cart').parent().find('#data_warning');
@@ -32,9 +32,9 @@ const cartHandlerMixin = {
this._rpc({
route: "/shop/cart/update_json",
params: params,
}).then(data => {
}).then(async data => {
await animateClone($('header .o_wsale_my_cart').first(), this.$itemImgContainer, 25, 40);
updateCartNavBar(data);
animateClone($('header .o_wsale_my_cart').first(), this.$itemImgContainer, 25, 40);
});
},
};
@@ -89,7 +89,10 @@ function updateCartNavBar(data) {
_.each($qtyNavBar, function (qty) {
var $qty = $(qty);
$qty.parents('li:first').removeClass('d-none');
$qty.html(data.cart_quantity).hide().fadeIn(600);
$qty.addClass('o_mycart_zoom_animation').delay(300).queue(function () {
$(this).text(data.cart_quantity);
$(this).removeClass("o_mycart_zoom_animation").dequeue();
});
});
$(".js_cart_lines").first().before(data['website_sale.cart_lines']).end().remove();
$(".js_cart_summary").first().before(data['website_sale.short_cart_summary']).end().remove();
@@ -739,6 +739,11 @@ a.no-decoration {
box-shadow: 0 0 5px 10px rgba(240,8,0,0.4)!important;
}
.o_mycart_zoom_animation {
transform: scale(1.4);
transition: all 0.3s ease-in-out;
}
/* product recently viewed snippet */
.o_carousel_product_card {
@@ -92,11 +92,11 @@ const DynamicSnippetProducts = DynamicSnippetCarousel.extend({
add_qty: 1
},
}).then(function (data) {
wSaleUtils.updateCartNavBar(data);
var $navButton = $('header .o_wsale_my_cart').first();
var fetch = self._fetchData();
var animation = wSaleUtils.animateClone($navButton, $(ev.currentTarget).parents('.card'), 25, 40);
Promise.all([fetch, animation]).then(function (values) {
wSaleUtils.updateCartNavBar(data);
self._render();
});
});