{"version":3,"file":"index.js","sources":["../../src/scripts/pages/home.js"],"sourcesContent":["import \"lity/dist/lity.min.css\";\nimport \"@/styles/pages/home.scss\";\nimport gsap from \"gsap\";\nimport { ScrollTrigger } from \"gsap/ScrollTrigger\";\nimport Swiper from \"swiper\";\nimport { Navigation, Pagination } from \"swiper/modules\";\nimport \"waypoints/lib/noframework.waypoints.min.js\";\nimport \"paginationjs\";\nimport counterUp from \"counterup2\";\nimport \"lity/dist/lity.min.js\";\n\ngsap.registerPlugin(ScrollTrigger);\n\n// check the screen size at first\nconst isLargeScreen = $(window).width() >= 1400;\nconst isAboveMd2 = $(window).width() >= 992;\n\n// Dom is ready\n$(function () {\n $(\".tab\").on(\"click\", function () {\n $(\".tab\").removeClass(\"active\");\n $(this).addClass(\"active\");\n currentPerformanceType = $(this).data(\"tab\");\n resetformanInit();\n });\n\n // video\n $(\".button-play\").on(\"click\", function (e) {\n e.preventDefault();\n });\n\n $(document).on(\"lity:ready\", function (event, $lightbox) {\n $(\".lity-content\").append(\n '
※相關資料統計截⾄2023年12⽉
'\n );\n });\n\n if (isAboveMd2) {\n $(\".tab\").removeClass(\"active\");\n $('.tab[data-tab=\"all\"]').addClass(\"active\");\n } else {\n $(\".tab\").removeClass(\"active\");\n $('.tab[data-tab=\"climate\"]').addClass(\"active\");\n }\n\n keySectionPin();\n performanceInit();\n});\n\n// $(window).on(\"load\", async function () {\n// performanceInit();\n// });\n\n\n/** Counter **/\nconst initCounter = () => {\n $(\".counter\").each(function () {\n // Create a waypoint for each counter element\n const counterElement = this;\n new Waypoint({\n element: counterElement,\n handler: function () {\n // Trigger counterUp animation\n counterUp(counterElement, {\n duration: 1000,\n delay: 20,\n });\n // Destroy this waypoint after triggering\n this.destroy();\n },\n offset: \"bottom-in-view\", // Trigger when the bottom of the element is in view\n });\n });\n};\n\n/** Swiper **/\nconst swiperAwardsMobile = new Swiper(\".swiper.swiper__awards-mobile\", {\n modules: [Navigation, Pagination],\n spaceBetween: 30,\n slidesPerView: 1,\n pagination: {\n el: \".swiper__awards-mobile .swiper-pagination\",\n type: \"fraction\",\n formatFractionCurrent: function (number) {\n const myNum = String(number).padStart(2, \"0\");\n return myNum;\n },\n formatFractionTotal: function (number) {\n const myNum = String(number).padStart(2, \"0\");\n return myNum;\n },\n },\n navigation: {\n nextEl: \".swiper__awards-mobile .swiper-button-next\",\n prevEl: \".swiper__awards-mobile .swiper-button-prev\",\n },\n});\n\nconst swiperAwardsDesktop = new Swiper(\".swiper.swiper__awards-desktop\", {\n modules: [Navigation, Pagination],\n slidesPerView: \"auto\",\n spaceBetween: 12,\n pagination: {\n el: \".swiper__awards-desktop .swiper-pagination\",\n type: \"fraction\",\n formatFractionCurrent: function (number) {\n const myNum = String(number).padStart(2, \"0\");\n return myNum;\n },\n formatFractionTotal: function (number) {\n const myNum = String(number).padStart(2, \"0\");\n return myNum;\n },\n },\n navigation: {\n nextEl: \".swiper__awards-desktop .swiper-button-next\",\n prevEl: \".swiper__awards-desktop .swiper-button-prev\",\n },\n});\n\nconst swiperNews = new Swiper(\".swiper.swiper__news\", {\n slidesPerView: \"auto\",\n spaceBetween: 12,\n\n breakpoints: {\n 1180: {\n spaceBetween: 30,\n slidesPerView: \"4\",\n },\n },\n});\n\n/** pagination of Performance */\n\nlet currentPerformanceData = [];\nlet currentPerformanceType = $(window).width() >= 992 ? \"all\" : \"climate\";\nlet limit = isLargeScreen ? 5 : 4;\nconst performancePagination = $(\"#sec-performance .cus__pagination\");\n\nconst performanceInit = () => {\n performancePagination.pagination({\n dataSource: function (done) {\n $.ajax({\n type: \"GET\",\n url: \"data/performance.json\",\n success: function (response) {\n done(\n response.data.filter((item) => {\n if (currentPerformanceType !== \"all\") {\n return item.type === currentPerformanceType;\n } else {\n return response.data;\n }\n })\n );\n currentPerformanceData = response.data.filter((item) => {\n return item.type === currentPerformanceType;\n });\n },\n });\n },\n callback: function (currentPerformanceData, pagination) {\n if (pagination.totalNumber <= limit) {\n performancePagination.hide();\n } else {\n performancePagination.show();\n }\n\n let html = templating(currentPerformanceData);\n $(\".performance__card-wrapper\").html(html);\n initCounter();\n ScrollTrigger.refresh();\n },\n showNavigator: true,\n formatNavigator:\n \"