{ "version": 3, "sources": ["../../../Vettvangur.Heilsuvera/src/scripts/components/Sykurmagn/sugarNavigation.ts"], "sourcesContent": ["import { gsap } from \"gsap/all\";\n\nconst sugarNavigation = {\n\telContainer: document.querySelector(\".sykurmagn .navigation\"),\n\telTrigger: document.querySelector(\".sykurmagn .navigation__trigger\"),\n\telDropShadow: document.querySelector(\".sykurmagn .navigation__dropshadow\"),\n\tisActive: false,\n\tisFrontpage: !document.querySelector(\".sykurmagn .header--white\"),\n\tlastWindowHeight: 0,\n\n\tinit: (): void => {\n\t\tif (!sugarNavigation.elTrigger) return;\n\n\t\tsugarNavigation.elTrigger.addEventListener(\n\t\t\t\"click\",\n\t\t\tsugarNavigation.toggleNavigation,\n\t\t);\n\t\twindow.addEventListener(\"resize\", sugarNavigation.hideNavigationOnResize);\n\t},\n\n\tshowNavigation: (): void => {\n\t\tgsap\n\t\t\t.timeline()\n\t\t\t.set(\".navigation__trigger\", { clearProps: \"all\", overwrite: true }, 0)\n\t\t\t.to(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(1)\",\n\t\t\t\t{ duration: 0.2, ease: \"power3.out\", overwrite: true, y: 6 },\n\t\t\t\t0,\n\t\t\t)\n\t\t\t.to(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(3)\",\n\t\t\t\t{ duration: 0.2, ease: \"power3.out\", overwrite: true, y: -6 },\n\t\t\t\t0,\n\t\t\t)\n\t\t\t.set(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(2)\",\n\t\t\t\t{ overwrite: true, scale: 0 },\n\t\t\t\t0.2,\n\t\t\t)\n\t\t\t.to(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(1)\",\n\t\t\t\t{ duration: 1, ease: \"elastic.out\", rotation: -45 },\n\t\t\t\t0.2,\n\t\t\t)\n\t\t\t.to(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(3)\",\n\t\t\t\t{ duration: 1, ease: \"elastic.out\", rotation: 45 },\n\t\t\t\t0.2,\n\t\t\t);\n\n\t\tgsap\n\t\t\t.timeline()\n\t\t\t.set(\".navigation__link\", { opacity: 0, y: 21 }, 0)\n\t\t\t.set(\".navigation\", { opacity: 0 }, 0)\n\t\t\t.set(\".navigation\", { clipPath: \"inset(0px 0px 100% 0px)\" }, 0.02)\n\t\t\t.set(\".navigation\", { opacity: 1 }, 0.04)\n\t\t\t.to(\n\t\t\t\t\".navigation\",\n\t\t\t\t{\n\t\t\t\t\tclipPath: \"inset(0px 0px 0px 0px)\",\n\t\t\t\t\tease: \"power3.inOut\",\n\t\t\t\t\tduration: 0.7,\n\t\t\t\t},\n\t\t\t\t0.06,\n\t\t\t)\n\t\t\t.set(\n\t\t\t\t\".navigation__dropshadow\",\n\t\t\t\t{\n\t\t\t\t\tdisplay: \"block\",\n\t\t\t\t\topacity: !sugarNavigation.isFrontpage ? 0 : 1,\n\t\t\t\t},\n\t\t\t\t0.06,\n\t\t\t)\n\t\t\t.to(\n\t\t\t\t\".navigation__dropshadow\",\n\t\t\t\t{\n\t\t\t\t\ty: window.innerHeight,\n\t\t\t\t\tease: \"power3.inOut\",\n\t\t\t\t\tduration: 0.7,\n\t\t\t\t\tclearProps: \"all\",\n\t\t\t\t\tonUpdate: () => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!sugarNavigation.isFrontpage &&\n\t\t\t\t\t\t\tsugarNavigation.elDropShadow.getBoundingClientRect().top > 80\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tgsap.set(\".navigation__dropshadow\", { opacity: 1 });\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t0.06,\n\t\t\t)\n\t\t\t.to(\n\t\t\t\t\".navigation__link\",\n\t\t\t\t{\n\t\t\t\t\topacity: 1,\n\t\t\t\t\ty: 0,\n\t\t\t\t\tease: \"power3.out\",\n\t\t\t\t\tduration: 0.7,\n\t\t\t\t\tclearProps: \"all\",\n\t\t\t\t\tstagger: 0.1,\n\t\t\t\t},\n\t\t\t\t0.3,\n\t\t\t);\n\n\t\tgsap.set(document.body, { overflow: \"hidden\" });\n\t\tsugarNavigation.elContainer.classList.add(\"navigation--active\");\n\t\twindow.scrollTo(0, 0);\n\t},\n\n\thideNavigationOnResize: (): void => {\n\t\tconst currentHeight = window.innerHeight;\n\t\tconst verticalResize = currentHeight !== sugarNavigation.lastWindowHeight;\n\t\tsugarNavigation.lastWindowHeight = currentHeight;\n\n\t\tif (!verticalResize && sugarNavigation.isActive) {\n\t\t\tsugarNavigation.hideNavigation();\n\t\t\tsugarNavigation.isActive = false;\n\t\t}\n\t},\n\n\thideNavigation: (): void => {\n\t\tgsap\n\t\t\t.timeline()\n\t\t\t.set(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(1)\",\n\t\t\t\t{ overwrite: true, rotation: -45, y: 6 },\n\t\t\t\t0,\n\t\t\t)\n\t\t\t.set(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(2)\",\n\t\t\t\t{ overwrite: true, scale: 0 },\n\t\t\t\t0,\n\t\t\t)\n\t\t\t.set(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(3)\",\n\t\t\t\t{ overwrite: true, rotation: 45, y: -6 },\n\t\t\t\t0,\n\t\t\t)\n\t\t\t.to(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(1)\",\n\t\t\t\t{ duration: 0.2, ease: \"power3.out\", rotation: 0 },\n\t\t\t\t0,\n\t\t\t)\n\t\t\t.to(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(3)\",\n\t\t\t\t{ duration: 0.2, ease: \"power3.out\", rotation: 0 },\n\t\t\t\t0,\n\t\t\t)\n\t\t\t.set(\".navigation__trigger hr:nth-of-type(2)\", { clearProps: \"all\" }, 0.2)\n\t\t\t.to(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(1)\",\n\t\t\t\t{ clearProps: \"all\", duration: 1, ease: \"elastic.out\", y: 0 },\n\t\t\t\t0.2,\n\t\t\t)\n\t\t\t.to(\n\t\t\t\t\".navigation__trigger hr:nth-of-type(3)\",\n\t\t\t\t{ clearProps: \"all\", duration: 1, ease: \"elastic.out\", y: 0 },\n\t\t\t\t0.2,\n\t\t\t);\n\n\t\tgsap.set(\n\t\t\t\".navigation, .navigation__trigger, .navigation__link, .navigation__dropshadow\",\n\t\t\t{ clearProps: \"all\", overwrite: true },\n\t\t);\n\t\tgsap.set(document.body, { clearProps: \"all\", overwrite: true });\n\t\tsugarNavigation.elContainer.classList.remove(\"navigation--active\");\n\t},\n\n\ttoggleNavigation: (): void => {\n\t\tif (!sugarNavigation.isActive) {\n\t\t\tsugarNavigation.showNavigation();\n\t\t} else {\n\t\t\tsugarNavigation.hideNavigation();\n\t\t}\n\n\t\tsugarNavigation.isActive = !sugarNavigation.isActive;\n\t},\n};\n\nexport default sugarNavigation;\n"], "mappings": "4GAEA,IAAMA,EAAkB,CACvB,YAAa,SAAS,cAAc,wBAAwB,EAC5D,UAAW,SAAS,cAAc,iCAAiC,EACnE,aAAc,SAAS,cAAc,oCAAoC,EACzE,SAAU,GACV,YAAa,CAAC,SAAS,cAAc,2BAA2B,EAChE,iBAAkB,EAElB,KAAM,IAAY,CACZA,EAAgB,YAErBA,EAAgB,UAAU,iBACzB,QACAA,EAAgB,gBACjB,EACA,OAAO,iBAAiB,SAAUA,EAAgB,sBAAsB,EACzE,EAEA,eAAgB,IAAY,CAC3BC,EACE,SAAS,EACT,IAAI,uBAAwB,CAAE,WAAY,MAAO,UAAW,EAAK,EAAG,CAAC,EACrE,GACA,yCACA,CAAE,SAAU,GAAK,KAAM,aAAc,UAAW,GAAM,EAAG,CAAE,EAC3D,CACD,EACC,GACA,yCACA,CAAE,SAAU,GAAK,KAAM,aAAc,UAAW,GAAM,EAAG,EAAG,EAC5D,CACD,EACC,IACA,yCACA,CAAE,UAAW,GAAM,MAAO,CAAE,EAC5B,EACD,EACC,GACA,yCACA,CAAE,SAAU,EAAG,KAAM,cAAe,SAAU,GAAI,EAClD,EACD,EACC,GACA,yCACA,CAAE,SAAU,EA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SAAU,GAAI,EAAG,EAAG,EACvC,CACD,EACC,GACA,yCACA,CAAE,SAAU,GAAK,KAAM,aAAc,SAAU,CAAE,EACjD,CACD,EACC,GACA,yCACA,CAAE,SAAU,GAAK,KAAM,aAAc,SAAU,CAAE,EACjD,CACD,EACC,IAAI,yCAA0C,CAAE,WAAY,KAAM,EAAG,EAAG,EACxE,GACA,yCACA,CAAE,WAAY,MAAO,SAAU,EAAG,KAAM,cAAe,EAAG,CAAE,EAC5D,EACD,EACC,GACA,yCACA,CAAE,WAAY,MAAO,SAAU,EAAG,KAAM,cAAe,EAAG,CAAE,EAC5D,EACD,EAEDA,EAAK,IACJ,gFACA,CAAE,WAAY,MAAO,UAAW,EAAK,CACtC,EACAA,EAAK,IAAI,SAAS,KAAM,CAAE,WAAY,MAAO,UAAW,EAAK,CAAC,EAC9DD,EAAgB,YAAY,UAAU,OAAO,oBAAoB,CAClE,EAEA,iBAAkB,IAAY,CACxBA,EAAgB,SAGpBA,EAAgB,eAAe,EAF/BA,EAAgB,eAAe,EAKhCA,EAAgB,SAAW,CAACA,EAAgB,QAC7C,CACD,EAEOI,EAAQJ", "names": ["sugarNavigation", "gsapWithCSS", "currentHeight", "verticalResize", "sugarNavigation_default"] }