feat(checkout): Adiciona função que remove e adiciona o titulo do carrinho

This commit is contained in:
Filipe Quintanilha Evangelista 2022-12-18 23:40:08 -03:00
parent 70d7d85c63
commit 21562f322c

View File

@ -12,7 +12,8 @@ export default class Footer {
this.pagamentos();
this.certificado();
this.desenvolvimento();
this.mostraTitulo();
this.tiraTitulo();
this.titleCart();
this.buildSlickItems();
this.onUpdate();
}
@ -208,9 +209,24 @@ export default class Footer {
`;
}
mostraTitulo() {
tiraTitulo() {
if (this.checkoutVazio.style.cssText === "display: block;") {
$(this.titulo).attr("style", "");
}
}
titleCart() {
let target = this.checkoutVazio;
let config = { childList: true, attributes: true };
let observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === "attributes" && mutation.attributeName === "style") {
if (target.style.display === "none") this.titulo.classList.remove("hide");
else if (target.style.display === "block") this.titulo.classList.add("hide");
}
});
});
observer.observe(target, config);
}
}