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B,GAAG,QAAQ,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,qBAC5Be,KAAKrB,GAAGM,cAAc,mBAChBe,KAAKrB,GAAGiD,iBAAiB,kBAEhDD,EAAe/C,UAAUC,IAAI,eAE7B,IAAMgD,EAAa7C,SAAS8C,cAAcC,yBAAvB,8QAMnBJ,EAAeK,WAAWjB,YAAYc,GAEtC,IAAMI,EAAoBjC,KAAKrB,GAAGM,cAAc,wBAC9CiD,EAAclC,KAAKrB,GAAGM,cAAc,kBACpCkD,EAAcnC,KAAKrB,GAAGM,cAAc,kBAEtCe,KAAKoC,SAAW,IAAIb,EAAOI,EAAgB,CACzCU,YAAY,EACZC,cAAe,EACfC,aAAc,EACdC,MAAM,EACNC,UAAU,EACVC,WAAY,gBACZC,aAAc,iBACdC,WAAYX,EACZY,WAAYX,EACZY,WAAYX,S,gFAvCGX,G","sources":["webpack://jcb-golf/./src/js/components/globals.js","webpack://jcb-golf/./src/js/components/heroGallery.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 heroGallery {\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('.gallery--wrapper'),\r\n galleryItems = this.el.querySelector('.gallery--items'),\r\n galleryItemsLength = this.el.querySelectorAll('.gallery--item');\r\n\r\n galleryWrapper.classList.add('is-carousel');\r\n\r\n const galleryNav = document.createRange().createContextualFragment(`\r\n \r\n \r\n
\r\n `);\r\n\r\n galleryWrapper.parentNode.appendChild(galleryNav);\r\n\r\n const galleryPagination = this.el.querySelector('.gallery--pagination'),\r\n galleryNext = this.el.querySelector('.gallery--next'),\r\n galleryPrev = this.el.querySelector('.gallery--prev');\r\n\r\n this.carousel = new Swiper(galleryWrapper, {\r\n autoHeight: false,\r\n slidesPerView: 1,\r\n spaceBetween: 0,\r\n loop: true,\r\n observer: true,\r\n slideClass: 'gallery--item',\r\n wrapperClass: 'gallery--items',\r\n pagination: galleryPagination,\r\n nextButton: galleryNext,\r\n prevButton: galleryPrev,\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","heroGallery","init","initCarousel","galleryWrapper","querySelectorAll","galleryNav","createRange","createContextualFragment","parentNode","galleryPagination","galleryNext","galleryPrev","carousel","autoHeight","slidesPerView","spaceBetween","loop","observer","slideClass","wrapperClass","pagination","nextButton","prevButton"],"sourceRoot":""}