fix: Ajusta forma de adicionar o slick
This commit is contained in:
parent
af34814021
commit
7e74180095
@ -11,7 +11,8 @@ export default class Footer {
|
||||
this.events();
|
||||
this.buildIconList();
|
||||
this.buildDevelopedByList();
|
||||
this.buildSlickItems();
|
||||
await this.buildSlickItems();
|
||||
await this.addCarrossel();
|
||||
this.onUpdate();
|
||||
}
|
||||
|
||||
@ -29,14 +30,16 @@ export default class Footer {
|
||||
window.addEventListener("hashchange", this.onUpdate.bind(this));
|
||||
}
|
||||
|
||||
buildSlickItems() {
|
||||
const slickItems = fetch(
|
||||
async buildSlickItems() {
|
||||
const response = await fetch(
|
||||
"https://m3academy.myvtex.com/api/catalog_system/pub/products/search/?fq=productClusterIds:319"
|
||||
)
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
);
|
||||
|
||||
const responseJsonData = await response.json().then(function (data) {
|
||||
return data;
|
||||
});
|
||||
|
||||
const buildSlickItems = async function (data) {
|
||||
const slickItems = data.map((item) => {
|
||||
const div = document.createElement("div");
|
||||
|
||||
@ -66,19 +69,12 @@ export default class Footer {
|
||||
|
||||
return div;
|
||||
});
|
||||
|
||||
return slickItems;
|
||||
});
|
||||
|
||||
const buildSlickItems = () => {
|
||||
slickItems.then((items) => {
|
||||
items.forEach((item) => {
|
||||
await slickItems.forEach((item) => {
|
||||
this.footerPrateleira.appendChild(item);
|
||||
});
|
||||
});
|
||||
};
|
||||
}.bind(this);
|
||||
|
||||
buildSlickItems();
|
||||
await buildSlickItems(responseJsonData);
|
||||
}
|
||||
|
||||
buildIconList() {
|
||||
@ -164,18 +160,10 @@ export default class Footer {
|
||||
let observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach(
|
||||
function (mutation) {
|
||||
console.log(mutation);
|
||||
if (mutation.type === "attributes" && mutation.attributeName === "style") {
|
||||
if (target.style.display === "none") {
|
||||
console.log("carrinho cheio");
|
||||
if (target.style.display === "none")
|
||||
this.footerPrateleira.style.display = "";
|
||||
|
||||
if (!this.footerPrateleira.classList.contains("slick-initialized"))
|
||||
this.addCarrossel();
|
||||
} else {
|
||||
this.footerPrateleira.style.display = "none";
|
||||
console.log("carrinho vazio");
|
||||
}
|
||||
else this.footerPrateleira.style.display = "none";
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
@ -184,9 +172,9 @@ export default class Footer {
|
||||
observer.observe(target, config);
|
||||
}
|
||||
|
||||
addCarrossel() {
|
||||
async addCarrossel() {
|
||||
const elemento = this.footerPrateleira;
|
||||
$(elemento).slick({
|
||||
await $(elemento).slick({
|
||||
slidesToShow: 4,
|
||||
slidesToScroll: 1,
|
||||
responsive: [
|
||||
|
Loading…
x
Reference in New Issue
Block a user