{"version":3,"sources":["/Users/user/afs-redesign/frontend/source/assets/js/split-screen.js"],"names":["ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","value","configurable","writable","document","addEventListener","isDesktop","window","innerWidth","shiftElementsRelativeToScrollbar","shiftWidth","body","style","paddingRight","concat","popups","querySelectorAll","popup","marginRight","goUpButtons","button","hideShowScroll","classList","add","scrollBarWidth","setTimeout","remove","setBackground","element","pic","querySelector","icon","getAttribute","animateBackground","scrollOptions","elem","str","offset","triggerElement","triggerHook","calcScrollPos","bgImage","undefined","nextElementSibling","getBoundingClientRect","top","innerHeight","previousElementSibling","initController","controllerScrollPanel","ScrollMagic","Controller","reInitScroll","scrollTo","newpos","destroyScrollPanels","gsap","to","duration","scrollPanelScenes","scrollY","reInitScrollPanels","handleResize","doneResizing","clearTimeout","resizeTimer","destroy","scrollSceneDefaultForward","scrollSceneDefaultReverse","scrollContainers","scrollContainer","attachBackground","firstScreen","pageYOffset","lastScreen","parentNode","contains","singleBlockImageContainer","backgroundImage","scrollSections","index","array","forwardScrollPos","Scene","on","event","scrollDirection","addTo","reversedScrollSections","reverseScrollPos","clientWidth","getPaginationConfig","swiper","isCustom","paginationWrapper","enabled","type","el","clickable","pictureSlider","pictureSwiper","Swiper","speed","spaceBetween","slidesPerView","effect","fadeEffect","crossFade","pagination","infosSlider","controller","control"],"mappings":"AAAA,YAEA,SAASA,SAAQC,EAAQC,GAAkB,GAAIC,GAAOC,OAAOD,KAAKF,EAAS,IAAIG,OAAOC,sBAAuB,CAAE,GAAIC,GAAUF,OAAOC,sBAAsBJ,EAASC,KAAmBI,EAAUA,EAAQC,OAAO,SAAUC,GAAO,MAAOJ,QAAOK,yBAAyBR,EAAQO,GAAKE,cAAiBP,EAAKQ,KAAKC,MAAMT,EAAMG,GAAY,MAAOH,GAE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,IAAeT,IACjBS,EAAYC,WAAWC,QAAUX,EACjCA,EAAcU,WAAWC,QAAUF","file":"split-screen.min.js","sourcesContent":["document.addEventListener(\"DOMContentLoaded\", () => {\n let isDesktop = window.innerWidth >= '1200';\n\n if (isDesktop) {\n (function gsapScrollPanel() {\n const scrollBarWidth = window.innerWidth - document.body.clientWidth;\n\n let controllerScrollPanel,\n scrollSceneDefaultForward,\n scrollSceneDefaultReverse,\n resizeTimer;\n\n const scrollContainers = document.querySelectorAll(\".split-screens-block-container:not(.split-screens-block-container--mobile) .split-screens-block\");\n\n // If the .fullpage container exists, set up the fullpage section animations\n if (scrollContainers) {\n initController();\n handleResize();\n }\n\n function shiftElementsRelativeToScrollbar(shiftWidth) {\n document.body.style.paddingRight = `${shiftWidth}px`;\n\n const popups = document.querySelectorAll(\".popup__content\");\n\n if (popups.length) {\n popups.forEach(popup => {\n popup.style.marginRight = `${shiftWidth}px`;\n })\n }\n\n const goUpButtons = document.querySelectorAll(\".go-up-button\");\n\n if (goUpButtons.length) {\n goUpButtons.forEach(button => {\n button.style.marginRight = `${shiftWidth}px`;\n })\n }\n }\n\n function hideShowScroll() {\n document.body.classList.add('scroll-disabled');\n shiftElementsRelativeToScrollbar(scrollBarWidth);\n\n setTimeout(function() {\n document.body.classList.remove('scroll-disabled');\n shiftElementsRelativeToScrollbar(0);\n },1000)\n }\n\n function setBackground(element) {\n const pic = element.querySelector(\".split-screen-block-picture img\");\n const icon = element.querySelector(\".split-screen-block-picture .branding-icon\");\n return `url(${icon ? icon.getAttribute(\"src\") : null}), url('${pic.getAttribute(\"src\")}')`;\n }\n\n function animateBackground(element) {\n element.classList.add('animated');\n setTimeout(() => {\n element.classList.remove('animated');\n }, 1000);\n }\n\n\n function scrollOptions(elem, str) {\n return str === 'enter' ?\n {\n offset: 40,\n triggerElement: elem,\n triggerHook: 0\n } :\n {\n offset: 0,\n triggerElement: elem,\n triggerHook: 0.3\n }\n }\n\n function calcScrollPos(elem, str, bgImage = null) {\n if (str === 'next') {\n return elem.nextElementSibling ?\n elem.nextElementSibling.getBoundingClientRect().top - 80 :\n elem.getBoundingClientRect().top + window.innerHeight + 40 - 80\n } else {\n return elem.previousElementSibling !== bgImage ?\n elem.previousElementSibling.getBoundingClientRect().top - 80\n : elem.getBoundingClientRect().top - window.innerHeight - 129 - 100 ;\n }\n }\n\n // Initialize the scrollMagic controller\n function initController() {\n // Init new controller\n controllerScrollPanel = new ScrollMagic.Controller();\n let reInitScroll = false;\n\n // Change behaviour of controller to animate scroll instead of jump\n controllerScrollPanel.scrollTo(function (newpos) {\n if (!reInitScroll) {\n gsap.to(window, {duration: 0.5, scrollTo: newpos});\n } else {\n destroyScrollPanels();\n reInitScroll = false;\n }\n });\n\n\n // Init the forward and reverse scenes\n scrollPanelScenes();\n\n document.addEventListener(\"destroyScrollPanels\", function(_) {\n reInitScroll = true;\n });\n\n window.addEventListener('scroll', () => {\n if (window.scrollY === 0) {\n destroyScrollPanels();\n reInitScrollPanels();\n }\n })\n }\n\n\n // If window is resized, destroy controller and reset once resize has stopped\n function handleResize() {\n function doneResizing(){\n reInitScrollPanels();\n }\n window.addEventListener('resize', (function() {\n destroyScrollPanels();\n clearTimeout(resizeTimer);\n resizeTimer = setTimeout(doneResizing, 500);\n }));\n }\n\n\n // Destroy scroll panels\n function destroyScrollPanels() {\n controllerScrollPanel.destroy();\n scrollSceneDefaultForward.destroy();\n scrollSceneDefaultReverse.destroy();\n }\n\n\n // Re-init scroll panels\n function reInitScrollPanels() {\n controllerScrollPanel = null;\n scrollSceneDefaultForward = null;\n scrollSceneDefaultReverse = null;\n initController();\n }\n\n // The forward and reverse scenes\n function scrollPanelScenes() {\n // Create scenes for panels, when scrolling forward\n if (scrollContainers) {\n scrollContainers.forEach((scrollContainer) => {\n const firstScreen = scrollContainer.querySelector(\".split-screen-block\");\n const lastScreen = scrollContainer.querySelector(\".split-screen-block:last-child\");\n const bgImage = scrollContainer.querySelector('.split-screen-block-bg-image');\n\n if (!scrollContainer.parentNode.classList.contains('split-screens-block-container--single')) {\n const scrollSections = scrollContainer.querySelectorAll('.split-screen-block');\n scrollSections.forEach(function(elem, index, array) {\n bgImage.style.backgroundImage = setBackground(array[0]);\n\n const forwardScrollPos = calcScrollPos(elem, 'next')\n\n scrollSceneDefaultForward = new ScrollMagic.Scene(scrollOptions(elem, 'enter'))\n .on('start', function(event) {\n if (event.scrollDirection == 'FORWARD') {\n controllerScrollPanel.scrollTo(forwardScrollPos); // If direction is forward, trigger scrollTo\n } else if (event.scrollDirection == 'REVERSE') {\n // Do nothing\n }\n })\n // Prevent problems with momentum scrolling by pausing for a period of time\n .on('enter', function(event) {\n hideShowScroll();\n })\n .addTo(controllerScrollPanel);\n\n new ScrollMagic.Scene(scrollOptions(elem, 'enter'))\n // Prevent problems with momentum scrolling by pausing for a period of time\n .on('enter', function(event) {\n if (array[index + 1]) {\n animateBackground(bgImage);\n bgImage.style.backgroundImage = setBackground(array[index + 1]);\n }\n })\n .addTo(controllerScrollPanel);\n })\n\n const reversedScrollSections = scrollContainer.querySelectorAll('.split-screen-block:nth-child(n+2)');\n\n // Create scenes for panels, when scrolling reverse\n reversedScrollSections.forEach(function(elem, index, array) {\n const reverseScrollPos = calcScrollPos(elem, 'prev', bgImage)\n\n scrollSceneDefaultReverse = new ScrollMagic.Scene(scrollOptions(elem))\n .on('start', function(event) {\n if (event.scrollDirection == 'FORWARD') {\n // Do nothing\n } else if (event.scrollDirection == 'REVERSE') {\n controllerScrollPanel.scrollTo(reverseScrollPos); // If direction is reverse, trigger scrollTo\n }\n })\n // Prevent problems with momentum scrolling by pausing for a period of time\n .on('leave', function(event) {\n hideShowScroll();\n })\n .addTo(controllerScrollPanel);\n\n new ScrollMagic.Scene(scrollOptions(elem))\n .on('leave', function() {\n if (array[index - 1]) {\n animateBackground(bgImage);\n bgImage.style.backgroundImage = setBackground(array[index - 1]);\n }\n })\n .addTo(controllerScrollPanel);\n })\n\n } else {\n const singleBlockImageContainer = scrollContainer.querySelector('.split-screen-block');\n if (singleBlockImageContainer) {\n bgImage.style.backgroundImage = setBackground(singleBlockImageContainer)\n }\n }\n\n function attachBackground() {\n if (window.scrollY >= firstScreen.getBoundingClientRect().top+pageYOffset - 80 && window.scrollY < lastScreen.getBoundingClientRect().top+pageYOffset + 100) {\n bgImage.classList.add(\"attached\");\n } else {\n if (window.scrollY >= lastScreen.getBoundingClientRect().top+pageYOffset) {\n bgImage.classList.add(\"bottom-bg\");\n } else {\n bgImage.classList.remove(\"bottom-bg\")\n }\n\n bgImage.classList.remove(\"attached\")\n }\n }\n\n if (!scrollContainer.parentNode.classList.contains('split-screens-block-container--single')) {\n window.addEventListener(\"scroll\", attachBackground)\n }\n })\n }\n }\n }());\n };\n\n (function createMobileSlider() {\n function getPaginationConfig(swiper, isCustom = false) {\n const paginationWrapper = swiper.parentNode.querySelector(\".swiper-pagination\")\n if (!paginationWrapper) {\n return {\n enabled: false,\n }\n }\n\n const type = !isCustom\n ? { type: \"bullets\" }\n : {\n type: \"custom\",\n }\n\n return {\n el: swiper.parentNode.querySelector(\".swiper-pagination\"),\n clickable: true,\n enabled: true,\n ...type,\n }\n }\n\n const pictureSlider = document.querySelector('.split-screen-pictures-container');\n\n if (pictureSlider) {\n const pictureSwiper = new Swiper('.split-screen-pictures-container', {\n speed: 800,\n spaceBetween: 0,\n slidesPerView: 1,\n effect: 'fade',\n fadeEffect: {\n crossFade: true\n },\n pagination: getPaginationConfig(pictureSlider)\n });\n\n\n const infosSlider = new Swiper('.split-screen-infos-container', {\n speed: 800,\n spaceBetween: 0,\n slidesPerView: 1.2,\n effect: 'slide',\n });\n\n if (infosSlider && pictureSwiper) {\n infosSlider.controller.control = pictureSwiper;\n pictureSwiper.controller.control = infosSlider;\n }\n }\n }())\n})\n"]}