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