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