zz-shopify-components 0.15.1-beta.2 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zz-shopify-components",
3
- "version": "0.15.1-beta.2",
3
+ "version": "0.16.0",
4
4
  "description": "Reusable Shopify components for theme projects",
5
5
  "keywords": [
6
6
  "shopify",
@@ -580,6 +580,7 @@
580
580
  >
581
581
  <div
582
582
  id='{{ banner.id }}-bannerlink'
583
+ data-banner-name="{{ banner.settings.banner_name }}"
583
584
  class='{{ banner.id }}-site-event swiper-content tw-w-full tw-max-w-screen tw-relative tw-text-left tw-h-full'
584
585
  >
585
586
  {%- if banner.type == 'img' -%}
@@ -937,5 +938,37 @@
937
938
  }
938
939
  }
939
940
  }
941
+
942
+ function handleBannerShow() {
943
+ // 监听滚动,高亮 tab
944
+ const observerOptions = {
945
+ root: null,
946
+ rootMargin: '0px 0px 0px 0px',
947
+ threshold: 0.5
948
+ };
949
+
950
+ const observer = new IntersectionObserver(entries => {
951
+ entries.forEach(entry => {
952
+ if (entry.isIntersecting) {
953
+ const bannerName = entry.target.dataset.bannerName;
954
+ console.log('banner_show', bannerName);
955
+ dataLayer.push({
956
+ event: "banner_show",
957
+ timestamp: new Date().toISOString(),
958
+ event_type_attribute: bannerName,
959
+ section_name: "swiper_banner_v3",
960
+ });
961
+ }
962
+
963
+ });
964
+ }, observerOptions);
965
+
966
+ const banner = document.querySelectorAll('[data-banner-name]');
967
+ banner.forEach(item => {
968
+ observer.observe(item);
969
+ });
970
+
971
+ }
972
+ handleBannerShow();
940
973
  })
941
974
  </script>