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