@whitesev/pops 2.3.4 → 2.3.6
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.amd.js +53 -18
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +53 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +53 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +53 -18
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +53 -18
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +53 -18
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/PopsCore.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -183,9 +183,19 @@ var pops = (function () {
|
|
|
183
183
|
window: window,
|
|
184
184
|
globalThis: globalThis,
|
|
185
185
|
self: self,
|
|
186
|
+
setTimeout: globalThis.setTimeout.bind(globalThis),
|
|
187
|
+
setInterval: globalThis.setInterval.bind(globalThis),
|
|
188
|
+
clearTimeout: globalThis.clearTimeout.bind(globalThis),
|
|
189
|
+
clearInterval: globalThis.clearInterval.bind(globalThis),
|
|
186
190
|
};
|
|
187
191
|
const PopsCoreEnv = Object.assign({}, PopsCoreDefaultEnv);
|
|
188
192
|
const PopsCore = {
|
|
193
|
+
init(option) {
|
|
194
|
+
if (!option) {
|
|
195
|
+
option = Object.assign({}, PopsCoreDefaultEnv);
|
|
196
|
+
}
|
|
197
|
+
Object.assign(PopsCoreEnv, option);
|
|
198
|
+
},
|
|
189
199
|
get document() {
|
|
190
200
|
return PopsCoreEnv.document;
|
|
191
201
|
},
|
|
@@ -198,6 +208,18 @@ var pops = (function () {
|
|
|
198
208
|
get self() {
|
|
199
209
|
return PopsCoreEnv.self;
|
|
200
210
|
},
|
|
211
|
+
get setTimeout() {
|
|
212
|
+
return PopsCoreEnv.setTimeout;
|
|
213
|
+
},
|
|
214
|
+
get setInterval() {
|
|
215
|
+
return PopsCoreEnv.setInterval;
|
|
216
|
+
},
|
|
217
|
+
get clearTimeout() {
|
|
218
|
+
return PopsCoreEnv.clearTimeout;
|
|
219
|
+
},
|
|
220
|
+
get clearInterval() {
|
|
221
|
+
return PopsCoreEnv.clearInterval;
|
|
222
|
+
},
|
|
201
223
|
};
|
|
202
224
|
const OriginPrototype = {
|
|
203
225
|
Object: {
|
|
@@ -716,7 +738,7 @@ var pops = (function () {
|
|
|
716
738
|
return setTimeout$1(callback, timeout);
|
|
717
739
|
}
|
|
718
740
|
catch (error) {
|
|
719
|
-
return
|
|
741
|
+
return PopsCore.setTimeout(callback, timeout);
|
|
720
742
|
}
|
|
721
743
|
}
|
|
722
744
|
/**
|
|
@@ -731,7 +753,7 @@ var pops = (function () {
|
|
|
731
753
|
catch (error) {
|
|
732
754
|
}
|
|
733
755
|
finally {
|
|
734
|
-
|
|
756
|
+
PopsCore.clearTimeout(timeId);
|
|
735
757
|
}
|
|
736
758
|
}
|
|
737
759
|
/**
|
|
@@ -742,7 +764,7 @@ var pops = (function () {
|
|
|
742
764
|
return setInterval$1(callback, timeout);
|
|
743
765
|
}
|
|
744
766
|
catch (error) {
|
|
745
|
-
return
|
|
767
|
+
return PopsCore.setInterval(callback, timeout);
|
|
746
768
|
}
|
|
747
769
|
}
|
|
748
770
|
/**
|
|
@@ -757,7 +779,7 @@ var pops = (function () {
|
|
|
757
779
|
catch (error) {
|
|
758
780
|
}
|
|
759
781
|
finally {
|
|
760
|
-
|
|
782
|
+
PopsCore.clearInterval(timeId);
|
|
761
783
|
}
|
|
762
784
|
}
|
|
763
785
|
}
|
|
@@ -10745,28 +10767,42 @@ var pops = (function () {
|
|
|
10745
10767
|
popsDOMUtils.addClassName(menuLiElement, `pops-${popsType}-item`);
|
|
10746
10768
|
}
|
|
10747
10769
|
/* 鼠标|触摸 移入事件 */
|
|
10748
|
-
|
|
10770
|
+
// 在移动端会先触发touchstart再然后mouseenter
|
|
10771
|
+
let isTriggerTouchEvent = false;
|
|
10772
|
+
/**
|
|
10773
|
+
* 鼠标|触摸 移入事件
|
|
10774
|
+
*/
|
|
10775
|
+
function liElementHoverEvent(event) {
|
|
10776
|
+
if (event.type === "touchstart") {
|
|
10777
|
+
isTriggerTouchEvent = true;
|
|
10778
|
+
}
|
|
10779
|
+
if (isTriggerTouchEvent && event.type === "mouseenter") {
|
|
10780
|
+
return;
|
|
10781
|
+
}
|
|
10749
10782
|
Array.from(menuULElement.children).forEach((liElement) => {
|
|
10750
10783
|
popsDOMUtils.removeClassName(liElement, `pops-${popsType}-is-visited`);
|
|
10751
|
-
|
|
10784
|
+
let li_menuData = Reflect.get(liElement, "__menuData__");
|
|
10785
|
+
if (!li_menuData) {
|
|
10752
10786
|
return;
|
|
10753
10787
|
}
|
|
10754
10788
|
function removeElement(element) {
|
|
10755
|
-
element.querySelectorAll("ul li").forEach((ele) => {
|
|
10756
|
-
|
|
10757
|
-
|
|
10789
|
+
element.querySelectorAll("ul li").forEach(($ele) => {
|
|
10790
|
+
let menuData = Reflect.get($ele, "__menuData__");
|
|
10791
|
+
if (menuData?.child) {
|
|
10792
|
+
removeElement(menuData.child);
|
|
10758
10793
|
}
|
|
10759
10794
|
});
|
|
10760
10795
|
element.remove();
|
|
10761
10796
|
}
|
|
10762
10797
|
/* 遍历根元素的上的__menuData__.child,判断 */
|
|
10763
|
-
removeElement(
|
|
10798
|
+
removeElement(li_menuData.child);
|
|
10764
10799
|
});
|
|
10765
10800
|
/* 清理根元素上的children不存在于页面中的元素 */
|
|
10766
|
-
|
|
10767
|
-
|
|
10801
|
+
let root_menuData = Reflect.get(rootElement, "__menuData__");
|
|
10802
|
+
for (let index = 0; index < root_menuData.child.length; index++) {
|
|
10803
|
+
let element = root_menuData.child[index];
|
|
10768
10804
|
if (!$shadowRoot.contains(element)) {
|
|
10769
|
-
|
|
10805
|
+
root_menuData.child.splice(index, 1);
|
|
10770
10806
|
index--;
|
|
10771
10807
|
}
|
|
10772
10808
|
}
|
|
@@ -10779,14 +10815,13 @@ var pops = (function () {
|
|
|
10779
10815
|
clientX: rect.left + popsDOMUtils.outerWidth(menuLiElement),
|
|
10780
10816
|
clientY: rect.top,
|
|
10781
10817
|
}, item.item, rootElement, menuLiElement, menuListenerRootNode);
|
|
10782
|
-
menuLiElement
|
|
10818
|
+
Reflect.set(menuLiElement, "__menuData__", {
|
|
10783
10819
|
child: childMenu,
|
|
10784
|
-
};
|
|
10820
|
+
});
|
|
10785
10821
|
}
|
|
10786
10822
|
/**
|
|
10787
10823
|
* 点击事件
|
|
10788
10824
|
* @param clickEvent
|
|
10789
|
-
* @returns
|
|
10790
10825
|
*/
|
|
10791
10826
|
async function liElementClickEvent(clickEvent) {
|
|
10792
10827
|
if (typeof item.callback === "function") {
|
|
@@ -10809,9 +10844,9 @@ var pops = (function () {
|
|
|
10809
10844
|
});
|
|
10810
10845
|
PopsContextMenu.closeAllMenu(rootElement);
|
|
10811
10846
|
}
|
|
10812
|
-
popsDOMUtils.on(menuLiElement, "mouseenter touchstart",
|
|
10847
|
+
popsDOMUtils.on(menuLiElement, "mouseenter touchstart", liElementHoverEvent);
|
|
10813
10848
|
/* 项-点击事件 */
|
|
10814
|
-
popsDOMUtils.on(menuLiElement, "click",
|
|
10849
|
+
popsDOMUtils.on(menuLiElement, "click", liElementClickEvent);
|
|
10815
10850
|
menuULElement.appendChild(menuLiElement);
|
|
10816
10851
|
});
|
|
10817
10852
|
},
|