{"version":3,"sources":["webpack://[name]/./src/js/components/ScrollDirectionComponent.js"],"names":["ScrollDirectionComponent","_BaseComponent","element","_this","_classCallCheck","_callSuper","observeScroll","_inherits","_createClass","key","get","up","down","active","trigger","value","_this2","window","addEventListener","e","targetToActivate","document","querySelectorAll","SELECTORS","forEach","target","scrollY","classList","add","CLASSES","remove","closest","deltaY","$el","this","$options","upIfZero","BaseComponent"],"mappings":"keAAuD,IAElCA,EAAwB,SAAAC,GAe3C,SAAAD,EAAYE,GAAS,IAAAC,EAIE,OAJFC,IAAA,KAAAJ,IACnBG,EAAAE,EAAA,KAAAL,EAAA,CAAME,KAGDI,gBAAgBH,EACtB,OAAAI,IAAAP,EAAAC,GAAAO,IAAAR,EAAA,EAAAS,IAAA,UAAAC,IAnBD,WACE,MAAO,CACLC,GAAI,YACJC,KAAM,cACNC,OAAQ,YAEX,CAAAJ,IAAA,YAAAC,IAED,WACE,MAAO,CACLI,QAAS,4BAEZ,CAAAL,IAAA,gBAAAM,MASD,WAAgB,IAAAC,EAAA,KACdC,OAAOC,iBAAiB,SAAS,SAACC,GAEhC,IAAMC,EAAmBC,SAASC,iBAAiBN,EAAKO,UAAUT,SAclE,GAZIM,GACFA,EAAiBI,SAAQ,SAAAC,GACpBR,OAAOS,SAAW,GACnBD,EAAOE,UAAUC,IAAIZ,EAAKa,QAAQhB,QAElCY,EAAOE,UAAUG,OAAOd,EAAKa,QAAQhB,aAOvCM,EAAEM,OAAOM,QAAQ,gCAAkCZ,EAAEM,OAAOM,QAAQ,4BAA8BZ,EAAEM,OAAOM,QAAQ,cAMvH,OAFkBZ,EAAEa,OAAS,EAAI,OAAS,MAGxC,IAAK,KACHhB,EAAKiB,IAAIN,UAAUG,OAAOd,EAAKa,QAAQjB,MACvCI,EAAKiB,IAAIN,UAAUC,IAAIZ,EAAKa,QAAQlB,IACpC,MACF,IAAK,OACHK,EAAKiB,IAAIN,UAAUG,OAAOd,EAAKa,QAAQlB,IACvCK,EAAKiB,IAAIN,UAAUC,IAAIZ,EAAKa,QAAQjB,MACpC,MACF,QACEI,EAAKiB,IAAIN,UAAUG,OAAOd,EAAKa,QAAQlB,IACvCK,EAAKiB,IAAIN,UAAUG,OAAOd,EAAKa,QAAQjB,UAK7CsB,KAAKC,SAASC,UAAYf,SAASH,iBAAiB,UAAU,WAGrC,IAAnBD,OAAOS,UACTV,EAAKiB,IAAIN,UAAUG,OAAOd,EAAKa,QAAQjB,MACvCI,EAAKiB,IAAIN,UAAUC,IAAIZ,EAAKa,QAAQlB,YAlEC,C,OAAS0B","file":"js/component-ScrollDirectionComponent-js.chunks.js","sourcesContent":["import BaseComponent from '../abstracts/BaseComponent';\n\nexport default class ScrollDirectionComponent extends BaseComponent {\n  get CLASSES() {\n    return {\n      up: 'scroll-up',\n      down: 'scroll-down',\n      active: 'active'\n    };\n  }\n\n  get SELECTORS() {\n    return {\n      trigger: '.js-activate-on-scroll',\n    };\n  }\n\n  constructor(element) {\n    super(element);\n    // console.log('ScrollDirectionComponent', 'this.$el', this.$el, 'this.$options.upIfZero', this.$options.upIfZero);\n\n    this.observeScroll();\n  }\n\n  observeScroll() {\n    window.addEventListener('wheel', (e) => {\n\n      const targetToActivate = document.querySelectorAll(this.SELECTORS.trigger);\n      \n      if (targetToActivate) {\n        targetToActivate.forEach(target => {\n          if(window.scrollY >= 30) {\n            target.classList.add(this.CLASSES.active);\n          } else {\n            target.classList.remove(this.CLASSES.active);\n          }\n        });\n\n      }\n\n      // PITTI20-90 PITTI20-913 PITTI20-1424\n      if (e.target.closest('.listing-grid-sidebar-right') || e.target.closest('.carousel-nav--vertical') || e.target.closest('.dropdown')) {\n        return;\n      }\n\n      const scrollDir = e.deltaY > 0 ? 'down' : 'up';\n\n      switch (scrollDir) {\n        case 'up':\n          this.$el.classList.remove(this.CLASSES.down);\n          this.$el.classList.add(this.CLASSES.up);\n          break;\n        case 'down':\n          this.$el.classList.remove(this.CLASSES.up);\n          this.$el.classList.add(this.CLASSES.down);\n          break;\n        default:\n          this.$el.classList.remove(this.CLASSES.up);\n          this.$el.classList.remove(this.CLASSES.down);\n      }\n    });\n\n    // PITTI20-1298\n    this.$options.upIfZero && document.addEventListener('scroll', () => {\n      // console.log('ScrollDirectionComponent', 'window.scrollY', window.scrollY);\n\n      if (window.scrollY === 0) {\n        this.$el.classList.remove(this.CLASSES.down);\n        this.$el.classList.add(this.CLASSES.up);\n      }\n    });\n  }\n}\n"],"sourceRoot":""}