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