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AQ,WACNzB,GACFA,QAzCR,IAAMG,EAAgBwB,EAAQ,KACxBpB,EAAaoB,EAAQ,O,wuBCA3B,U,qSACA,IAAMC,EAASD,EAAQ,MAEFE,EAAAA,WACnB,WAAY7C,I,4FAAI,SACdqB,KAAKrB,GAAKA,EACVqB,KAAKyB,O,2CAGP,WACEzB,KAAK0B,iB,0BAGP,WACE,IAAMC,EAAiB3B,KAAKrB,GAAGM,cAAc,sBAC5Be,KAAKrB,GAAGM,cAAc,oBAChBe,KAAKrB,GAAGiD,iBAAiB,mBAEhDD,EAAe/C,UAAUC,IAAI,eAE7B,IAAMgD,EAAa7C,SAAS8C,cAAcC,yBAAvB,iOAKnBJ,EAAeK,WAAWjB,YAAYc,GAEtC,IAAMI,EAAcjC,KAAKrB,GAAGM,cAAc,mBACxCiD,EAAclC,KAAKrB,GAAGM,cAAc,mBAEtCe,KAAKmC,SAAW,IAAIZ,EAAOI,EAAgB,CACzCS,YAAY,EACZC,cAAe,OACfC,aAAc,GACdC,MAAM,EACNC,aAAc,EACdC,UAAU,EACVC,WAAY,iBACZC,aAAc,kBACdC,WAAYX,EACZY,WAAYX,EACZY,YAAa,CACX,IAAK,CACHT,cAAe,a,gFAxCJb,G","sources":["webpack://jcb-golf/./src/js/components/globals.js","webpack://jcb-golf/./src/js/components/smallGallery.js"],"sourcesContent":["const ScrollWatcher = require(\"scroll-watcher\");\r\nconst inViewport = require('in-viewport');\r\n\r\n\r\nexport function watchScroll(el, onEnterCallback, onExitCallback, offset) {\r\n  const y = window.scrollY,\r\n        elY = el.offsetTop,\r\n        scroll = new ScrollWatcher(),\r\n        that = this;\r\n\r\n  let offsetAmount = offset || false;\r\n\r\n  if (!inViewport(el)) {\r\n    this.addUnseenClass(el);\r\n  }\r\n\r\n  if (!offsetAmount) {\r\n    const dummy = document.createElement(\"div\");\r\n    dummy.style.height = \"50vh\";\r\n    dummy.style.width = \"0\";\r\n    dummy.style.position = \"fixed\";\r\n    dummy.style.top = \"0\";\r\n    dummy.style.left = \"100%\"\r\n    document.body.appendChild(dummy);\r\n    const h = dummy.offsetHeight;\r\n    document.body.removeChild(dummy);\r\n    console.log(\"Offset height of\", h, \"px set for: \", el);\r\n    offsetAmount = h;\r\n  } else {\r\n    console.log(\"Offset height of\", offsetAmount, \"px already set for: \", el);\r\n  }\r\n\r\n  scroll.watch(el, offsetAmount)\r\n    .on(\"enter\", () => {\r\n      that.unhide(el);\r\n      if (onEnterCallback) {\r\n        onEnterCallback()\r\n      }\r\n    })\r\n    .on(\"exit\", () => {\r\n      if (onExitCallback) {\r\n        onExitCallback()\r\n      }\r\n    });\r\n\r\n}\r\n\r\nexport function addUnseenClass(el) {\r\n  el.classList.add(\"unseen\");\r\n}\r\n\r\nexport function unhide(el) {\r\n  el.classList.remove(\"unseen\");\r\n}\r\n\r\nexport function setNav(sectionId) {\r\n  const nav = document.querySelector(\"header nav\"),\r\n        currentActive = nav.querySelector(\".active\"),\r\n        targetActive = nav.querySelector(\"[href='\"+sectionId+\"']\");\r\n\r\n  if (currentActive) {\r\n    currentActive.classList.remove(\"active\");\r\n  }\r\n  targetActive.classList.add(\"active\");\r\n}\r\n\r\nexport function unsetNav(el, sectionId) {\r\n  const y = window.scrollY,\r\n        elY = el.offsetTop,\r\n        nav = document.querySelector(\"header nav\"),\r\n        currentActive = nav.querySelector(\".active\"),\r\n        targetActive = nav.querySelector(\"[href='\"+sectionId+\"']\");\r\n\r\n  if(y < elY) {\r\n    currentActive.classList.remove(\"active\");\r\n    targetActive.classList.add(\"active\");\r\n  }\r\n}","// TODO: JFED-002 - Update Swiper to latest\r\nimport * as globals from './globals.js';\r\nconst Swiper = require('swiper');\r\n\r\nexport default class smallGallery {\r\n  constructor(el) {\r\n    this.el = el;\r\n    this.init();\r\n  }\r\n\r\n  init() {\r\n    this.initCarousel();\r\n  }\r\n\r\n  initCarousel() {\r\n    const galleryWrapper = this.el.querySelector('.carousel--wrapper'),\r\n      galleryItems = this.el.querySelector('.carousel--items'),\r\n      galleryItemsLength = this.el.querySelectorAll('.carousel--item');\r\n\r\n    galleryWrapper.classList.add('is-carousel');\r\n\r\n    const galleryNav = document.createRange().createContextualFragment(`\r\n      <button class=\"carousel--prev\"><i class=\"fa fa-chevron-left\"></i><span>Previous slide</span></button>\r\n      <button class=\"carousel--next\"><i class=\"fa fa-chevron-right\"></i><span>Next slide</span></button>\r\n    `);\r\n\r\n    galleryWrapper.parentNode.appendChild(galleryNav);\r\n\r\n    const galleryNext = this.el.querySelector('.carousel--next'),\r\n      galleryPrev = this.el.querySelector('.carousel--prev');\r\n\r\n    this.carousel = new Swiper(galleryWrapper, {\r\n      autoHeight: false,\r\n      slidesPerView: 'auto',\r\n      spaceBetween: 10,\r\n      loop: true,\r\n      loopedSlides: 3,\r\n      observer: true,\r\n      slideClass: 'carousel--item',\r\n      wrapperClass: 'carousel--items',\r\n      nextButton: galleryNext,\r\n      prevButton: galleryPrev,\r\n      breakpoints: {\r\n        480: {\r\n          slidesPerView: 1.2,\r\n        },\r\n      },\r\n    });\r\n  }\r\n}\r\n"],"names":["el","classList","add","sectionId","nav","document","querySelector","currentActive","targetActive","remove","y","window","scrollY","elY","offsetTop","onEnterCallback","onExitCallback","offset","scroll","ScrollWatcher","that","this","offsetAmount","inViewport","addUnseenClass","console","log","dummy","createElement","style","height","width","position","top","left","body","appendChild","h","offsetHeight","removeChild","watch","on","unhide","require","Swiper","smallGallery","init","initCarousel","galleryWrapper","querySelectorAll","galleryNav","createRange","createContextualFragment","parentNode","galleryNext","galleryPrev","carousel","autoHeight","slidesPerView","spaceBetween","loop","loopedSlides","observer","slideClass","wrapperClass","nextButton","prevButton","breakpoints"],"sourceRoot":""}