@whitesev/pops 2.3.4 → 2.3.5

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.
@@ -10747,28 +10747,42 @@ System.register('pops', [], (function (exports) {
10747
10747
  popsDOMUtils.addClassName(menuLiElement, `pops-${popsType}-item`);
10748
10748
  }
10749
10749
  /* 鼠标|触摸 移入事件 */
10750
- function liElementHoverEvent() {
10750
+ // 在移动端会先触发touchstart再然后mouseenter
10751
+ let isTriggerTouchEvent = false;
10752
+ /**
10753
+ * 鼠标|触摸 移入事件
10754
+ */
10755
+ function liElementHoverEvent(event) {
10756
+ if (event.type === "touchstart") {
10757
+ isTriggerTouchEvent = true;
10758
+ }
10759
+ if (isTriggerTouchEvent && event.type === "mouseenter") {
10760
+ return;
10761
+ }
10751
10762
  Array.from(menuULElement.children).forEach((liElement) => {
10752
10763
  popsDOMUtils.removeClassName(liElement, `pops-${popsType}-is-visited`);
10753
- if (!liElement.__menuData__) {
10764
+ let li_menuData = Reflect.get(liElement, "__menuData__");
10765
+ if (!li_menuData) {
10754
10766
  return;
10755
10767
  }
10756
10768
  function removeElement(element) {
10757
- element.querySelectorAll("ul li").forEach((ele) => {
10758
- if (ele?.__menuData__?.child) {
10759
- removeElement(ele.__menuData__.child);
10769
+ element.querySelectorAll("ul li").forEach(($ele) => {
10770
+ let menuData = Reflect.get($ele, "__menuData__");
10771
+ if (menuData?.child) {
10772
+ removeElement(menuData.child);
10760
10773
  }
10761
10774
  });
10762
10775
  element.remove();
10763
10776
  }
10764
10777
  /* 遍历根元素的上的__menuData__.child,判断 */
10765
- removeElement(liElement.__menuData__.child);
10778
+ removeElement(li_menuData.child);
10766
10779
  });
10767
10780
  /* 清理根元素上的children不存在于页面中的元素 */
10768
- for (let index = 0; index < rootElement.__menuData__.child.length; index++) {
10769
- let element = rootElement.__menuData__.child[index];
10781
+ let root_menuData = Reflect.get(rootElement, "__menuData__");
10782
+ for (let index = 0; index < root_menuData.child.length; index++) {
10783
+ let element = root_menuData.child[index];
10770
10784
  if (!$shadowRoot.contains(element)) {
10771
- rootElement.__menuData__.child.splice(index, 1);
10785
+ root_menuData.child.splice(index, 1);
10772
10786
  index--;
10773
10787
  }
10774
10788
  }
@@ -10781,14 +10795,13 @@ System.register('pops', [], (function (exports) {
10781
10795
  clientX: rect.left + popsDOMUtils.outerWidth(menuLiElement),
10782
10796
  clientY: rect.top,
10783
10797
  }, item.item, rootElement, menuLiElement, menuListenerRootNode);
10784
- menuLiElement.__menuData__ = {
10798
+ Reflect.set(menuLiElement, "__menuData__", {
10785
10799
  child: childMenu,
10786
- };
10800
+ });
10787
10801
  }
10788
10802
  /**
10789
10803
  * 点击事件
10790
10804
  * @param clickEvent
10791
- * @returns
10792
10805
  */
10793
10806
  async function liElementClickEvent(clickEvent) {
10794
10807
  if (typeof item.callback === "function") {
@@ -10811,9 +10824,9 @@ System.register('pops', [], (function (exports) {
10811
10824
  });
10812
10825
  PopsContextMenu.closeAllMenu(rootElement);
10813
10826
  }
10814
- popsDOMUtils.on(menuLiElement, "mouseenter touchstart", void 0, liElementHoverEvent);
10827
+ popsDOMUtils.on(menuLiElement, "mouseenter touchstart", liElementHoverEvent);
10815
10828
  /* 项-点击事件 */
10816
- popsDOMUtils.on(menuLiElement, "click", void 0, liElementClickEvent);
10829
+ popsDOMUtils.on(menuLiElement, "click", liElementClickEvent);
10817
10830
  menuULElement.appendChild(menuLiElement);
10818
10831
  });
10819
10832
  },