{"version":3,"file":"specialties.min.js","sources":["scripts/specialties.min.js"],"sourcesContent":["/**************************************************************************\r\nName: specialties.js\r\nDescription: Scripts for specialty pages\r\nDate Created: 2024-02-12 by Owen Haggerty\r\nModified: \r\n**************************************************************************/\r\nfunction initSpecialtyPage(){\r\n\t/* Initializes parallax scroll effect on the header imagery */\r\n\tlet imageryWrapper = document.querySelector(\".specialtyHeaderImagery\");\r\n\tif(imageryWrapper === null) return;\r\n\tlet images = document.querySelectorAll(\".specialtyHeaderImagery > *\");\r\n\r\n\twindow.requestAnimationFrame(()=>{\r\n\t\tif(matchMedia(\"(prefers-reduced-motion)\").matches == false){\r\n\t\t\t//Autoplay the videos. If autoplay is set at page load, the videos will always be loaded,\r\n\t\t\t//even for users who won't see them\r\n\t\t\tdocument.querySelectorAll(\"video.autoplayVideo\").forEach(function(elem){\r\n\t\t\t\telem.setAttribute(\"autoplay\", true);\r\n\t\t\t});\r\n\t\t}\r\n\t});\r\n\r\n\t\r\n\t//Add the scroll effect listener\r\n\tsetSpecialtiesParallaxScroll();\r\n\t//Listen for changes to the prefers-reduced-motion preference\r\n\tmatchMedia(\"(prefers-reduced-motion) or (max-width: 768px)\").onchange = setSpecialtiesParallaxScroll;\r\n\r\n\tif(document.body.clientWidth > 768 && matchMedia(\"not (prefers-reduced-motion)\").matches){\r\n\t\t//Set up the load effect on the images\r\n\t\tlet video = document.querySelector(\".specialtyHeaderImagery video.autoplayVideo\");\r\n\t\tif(video !== null){\r\n\t\t\t//Pause the autoplaying video until the animation finishes\r\n\t\t\tvideo.pause();\r\n\t\t}\r\n\t\timages.forEach(function(e){\r\n\t\t\te.style.opacity = 0;\r\n\t\t\te.style.scale = 1.5;\r\n\t\t\t//Add opacity and scale transitions\r\n\t\t\tlet currentTransition = getComputedStyle(e).transition;\r\n\t\t\tcurrentTransition += \", opacity 1s ease, scale 1s ease\"\r\n\t\t\te.style.transition = currentTransition;\r\n\t\t});\r\n\t\t//Show the falling into place animation\r\n\t\twindow.requestAnimationFrame(function(){\r\n\t\t\tlet bgImage = imageryWrapper.querySelector(\".parallaxBackgroundImage\");\r\n\t\t\tif(bgImage !== null){\r\n\t\t\t\t//Show the background image falling into place\r\n\t\t\t\tbgImage.style.opacity = 1;\r\n\t\t\t\tbgImage.style.scale = 1;\r\n\t\t\t\tif(video !== null && bgImage.contains(video)){\r\n\t\t\t\t\twindow.setTimeout(()=>{\r\n\t\t\t\t\t\tvideo.play();\r\n\t\t\t\t\t}, 1000);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//Show the non-background images\r\n\t\t\twindow.setTimeout(function(){\r\n\t\t\t\timages.forEach(function(elem, index){\r\n\t\t\t\t\t//Show each element, with a short delay between them\r\n\t\t\t\t\twindow.setTimeout(()=>{\r\n\t\t\t\t\t\telem.style.opacity = 1;\r\n\t\t\t\t\t\telem.style.scale = 1;\r\n\t\t\t\t\t}, index * 150);\r\n\t\t\t\t});\r\n\t\t\t\tif(video !== null){\r\n\t\t\t\t\twindow.setTimeout(()=>{\r\n\t\t\t\t\t\tvideo.play();\r\n\t\t\t\t\t}, 1000);\r\n\t\t\t\t}\r\n\t\t\t}, 250);\r\n\t\t});\r\n\t}\r\n\telse{\r\n\t\t//Show the images without a transition\r\n\t\timages.forEach((img)=>{\r\n\t\t\timg.style.opacity = 1;\r\n\t\t});\r\n\t}\r\n}\r\n\r\nfunction setSpecialtiesParallaxScroll(){\r\n\t/* Sets or removes the parallax scroll effect on the headery imagery */\r\n\tlet imageryWrapper = document.querySelector(\".specialtyHeaderImagery\");\r\n\tif(imageryWrapper === null) return;\r\n\r\n\twindow.specialtyParallaxNextFrame = null;\r\n\tif(matchMedia(\"(prefers-reduced-motion) or (max-width: 768px)\").matches == false){\r\n\t\taddEventListener(\"scroll\", specialtiesOnScrollParallax);\r\n\t\t//Trigger a scroll to position the header images\r\n\t\tspecialtiesOnScrollParallax();\r\n\t}\r\n\telse{\r\n\t\tremoveEventListener(\"scroll\", specialtiesOnScrollParallax);\r\n\t\t//Remove the transform from all header images\r\n\t\tdocument.querySelectorAll(\".specialtyHeaderImagery > *\").forEach(function(element){\r\n\t\t\telement.style.transform = \"none\";\r\n\t\t});\r\n\t}\r\n\t//Re-compute the source of any autoplaying videos\r\n\tif(!window.matchMedia(\"(prefers-reduced-motion)\").matches){\r\n\t\tjQuery(\"video[autoplay],video.autoplayVideo\").each((i, e)=>{\r\n\t\t\te.load();\r\n\t\t\tif(!e.hasAttribute(\"autoplay\")){\r\n\t\t\t\te.setAttribute(\"autoplay\", true);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n}\r\n\r\nfunction specialtiesOnScrollParallax(){\r\n\t/* Positions the header imagery to produce the parallax effect on scroll */\r\n\tlet backgroundImage = document.querySelector(\".specialtyHeaderImagery > .parallaxBackgroundImage\");\r\n\tlet images = document.querySelectorAll(\".specialtyHeaderImagery > :not(.parallaxBackgroundImage)\");\r\n\r\n\tif(specialtyParallaxNextFrame !== null){\r\n\t\twindow.cancelAnimationFrame(specialtyParallaxNextFrame);\r\n\t}\r\n\r\n\twindow.requestAnimationFrame(()=>{\r\n\t\t//Set the positions for each image elment\r\n\t\timages.forEach((elem)=>{\r\n\t\t\telem.style.transform = `translateY(-${window.scrollY / 2}px)`;\r\n\t\t});\r\n\t\tif(backgroundImage !== null){\r\n\t\t\tbackgroundImage.style.transform = `translateY(-${window.scrollY / 1.5}px)`;\r\n\t\t}\r\n\t});\r\n}\r\n\r\n//Initialize the specialty page on window load or after 3 seconds, whichever comes first\r\nif(document.readyState === \"complete\"){\r\n\tinitSpecialtyPage();\r\n}\r\nelse{\r\n\tlet specialtiesIsLoaded = false;\r\n\twindow.setTimeout(()=>{\r\n\t\tif(specialtiesIsLoaded) return;\r\n\t\tinitSpecialtyPage();\r\n\t\tspecialtiesIsLoaded = true;\r\n\t}, 3000);\r\n\twindow.addEventListener(\"load\", ()=>{\r\n\t\tif(specialtiesIsLoaded) return;\r\n\t\tinitSpecialtyPage();\r\n\t\tspecialtiesIsLoaded = true;\r\n\t});\r\n}"],"names":["initSpecialtyPage","let","imageryWrapper","document","querySelector","images","querySelectorAll","window","requestAnimationFrame","matchMedia","matches","forEach","elem","setAttribute","setSpecialtiesParallaxScroll","onchange","body","clientWidth","video","pause","e","style","opacity","scale","currentTransition","getComputedStyle","transition","bgImage","contains","setTimeout","play","index","img","specialtyParallaxNextFrame","addEventListener","specialtiesOnScrollParallax","removeEventListener","element","transform","jQuery","each","i","load","hasAttribute","backgroundImage","cancelAnimationFrame","scrollY","readyState","specialtiesIsLoaded"],"mappings":"AAMA,SAASA,oBAERC,IAAIC,EAAiBC,SAASC,cAAc,2BAC5C,GAAsB,OAAnBF,EAAH,CACAD,IAAII,EAASF,SAASG,iBAAiB,+BAkBvC,GAhBAC,OAAOC,sBAAsB,KACyB,GAAlDC,WAAW,4BAA4BC,SAGzCP,SAASG,iBAAiB,uBAAuBK,QAAQ,SAASC,GACjEA,EAAKC,aAAa,YAAY,OAOjCC,+BAEAL,WAAW,kDAAkDM,SAAWD,6BAEzC,IAA5BX,SAASa,KAAKC,aAAqBR,WAAW,gCAAgCC,QAAQ,CAExFT,IAAIiB,EAAQf,SAASC,cAAc,+CACtB,OAAVc,GAEFA,EAAMC,QAEPd,EAAOM,QAAQ,SAASS,GACvBA,EAAEC,MAAMC,QAAU,EAClBF,EAAEC,MAAME,MAAQ,IAEhBtB,IAAIuB,EAAoBC,iBAAiBL,GAAGM,WAE5CN,EAAEC,MAAMK,WADRF,GAAqB,qCAItBjB,OAAOC,sBAAsB,WAC5BP,IAAI0B,EAAUzB,EAAeE,cAAc,4BAC5B,OAAZuB,IAEFA,EAAQN,MAAMC,QAAU,EACxBK,EAAQN,MAAME,MAAQ,EACT,OAAVL,GAAkBS,EAAQC,SAASV,IACrCX,OAAOsB,WAAW,KACjBX,EAAMY,QACJ,MAILvB,OAAOsB,WAAW,WACjBxB,EAAOM,QAAQ,SAASC,EAAMmB,GAE7BxB,OAAOsB,WAAW,KACjBjB,EAAKS,MAAMC,QAA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