diff --git a/src/arquivos/js/app/app.js b/src/arquivos/js/app/app.js index 0fef959..a04444f 100644 --- a/src/arquivos/js/app/app.js +++ b/src/arquivos/js/app/app.js @@ -64,7 +64,7 @@ const app = new Container({ ], }); -app.bind(Minicart.name, ".carrinho .mini-cart"); +app.bind(Minicart.name, ".minicart__drawer"); app.bind(Newsletter.name, { elemento: ".news-form", textButtom: "Cadastre-se", diff --git a/src/arquivos/js/app/components/FixedHeader.js b/src/arquivos/js/app/components/FixedHeader.js index 0916421..d691b1f 100644 --- a/src/arquivos/js/app/components/FixedHeader.js +++ b/src/arquivos/js/app/components/FixedHeader.js @@ -3,43 +3,28 @@ import { isSmallerThen768 } from "Helpers/MediasMatch"; export default class FixedHeader { constructor() { if (!isSmallerThen768) { - this.fixedHeader(); + this.selectors(); + this.events(); } } - fixedHeader() { - var lastScroll = 0; - var timer, scrollTop, headerHeight; - var element = $("header.header"); - - $(document).scroll(function (e) { - headerHeight = element.height(); - scrollTop = $(document).scrollTop(); - - if (scrollTop > 1) { - $("body").css("padding-top", headerHeight); - element.addClass("fixed"); - - if (timer) { - window.clearTimeout(timer); - } - - timer = window.setTimeout(function () { - if ( - scrollTop > lastScroll && - scrollTop > element.height() + 20 - ) { - element.addClass("fixed-hide"); - } else { - element.removeClass("fixed-hide"); - } - - lastScroll = $(document).scrollTop(); - }, 50); - } else { - element.removeClass("fixed"); - $("body").css("padding-top", 0); - } - }); + selectors() { + this.pageHeader = $(".page-header"); } + + events() { + $(document).scroll(this.fixHeader.bind(this)); + } + + fixHeader() { + const topScroll = $(document).scrollTop(); + console.log(topScroll) + + if (topScroll > 200) { + this.pageHeader.addClass('is-fixed') + } else { + this.pageHeader.removeClass('is-fixed') + } + } + } diff --git a/src/arquivos/js/app/components/Minicart.js b/src/arquivos/js/app/components/Minicart.js index f45f291..a2edb35 100644 --- a/src/arquivos/js/app/components/Minicart.js +++ b/src/arquivos/js/app/components/Minicart.js @@ -6,7 +6,7 @@ export default class Minicart { const structure = `