@whitesev/pops 1.8.9 → 1.9.0
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 +62 -37
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +62 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +62 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +62 -37
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +62 -37
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +62 -37
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +2 -2
- package/dist/types/src/handler/PopsHandler.d.ts +3 -1
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +11 -9
- package/package.json +1 -1
- package/src/components/panel/index.ts +5 -5
- package/src/handler/PopsHandler.ts +21 -16
- package/src/utils/PopsInstanceUtils.ts +44 -23
package/dist/index.iife.js
CHANGED
|
@@ -1667,6 +1667,8 @@ var pops = (function () {
|
|
|
1667
1667
|
/**
|
|
1668
1668
|
* 获取页面中最大的z-index的元素信息
|
|
1669
1669
|
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
1670
|
+
* @param node 进行判断的元素,默认是document
|
|
1671
|
+
* @param ignoreCallBack 执行元素处理时调用的函数,返回false可忽略不想要处理的元素
|
|
1670
1672
|
* @example
|
|
1671
1673
|
* Utils.getMaxZIndexNodeInfo();
|
|
1672
1674
|
* > {
|
|
@@ -1674,11 +1676,11 @@ var pops = (function () {
|
|
|
1674
1676
|
* zIndex: 1001
|
|
1675
1677
|
* }
|
|
1676
1678
|
**/
|
|
1677
|
-
getMaxZIndexNodeInfo(deviation = 1) {
|
|
1679
|
+
getMaxZIndexNodeInfo(deviation = 1, target = PopsCore.document, ignoreCallBack) {
|
|
1678
1680
|
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
1679
|
-
// 最大值2147483647
|
|
1680
|
-
const maxZIndex = Math.pow(2, 31) - 1;
|
|
1681
|
-
// 比较值2000000000
|
|
1681
|
+
// 最大值 2147483647
|
|
1682
|
+
// const maxZIndex = Math.pow(2, 31) - 1;
|
|
1683
|
+
// 比较值 2000000000
|
|
1682
1684
|
const maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
1683
1685
|
// 当前页面最大的z-index
|
|
1684
1686
|
let zIndex = 0;
|
|
@@ -1698,6 +1700,12 @@ var pops = (function () {
|
|
|
1698
1700
|
* @param $ele
|
|
1699
1701
|
*/
|
|
1700
1702
|
function queryMaxZIndex($ele) {
|
|
1703
|
+
if (typeof ignoreCallBack === "function") {
|
|
1704
|
+
let ignoreResult = ignoreCallBack($ele);
|
|
1705
|
+
if (typeof ignoreResult === "boolean" && !ignoreResult) {
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1701
1709
|
/** 元素的样式 */
|
|
1702
1710
|
const nodeStyle = PopsCore.window.getComputedStyle($ele);
|
|
1703
1711
|
/* 不对position为static和display为none的元素进行获取它们的z-index */
|
|
@@ -1718,48 +1726,48 @@ var pops = (function () {
|
|
|
1718
1726
|
}
|
|
1719
1727
|
}
|
|
1720
1728
|
}
|
|
1721
|
-
|
|
1729
|
+
target.querySelectorAll("*").forEach(($ele, index) => {
|
|
1722
1730
|
queryMaxZIndex($ele);
|
|
1723
1731
|
});
|
|
1724
1732
|
zIndex += deviation;
|
|
1725
1733
|
if (zIndex >= maxZIndexCompare) {
|
|
1726
1734
|
// 最好不要超过最大值
|
|
1727
|
-
zIndex =
|
|
1735
|
+
zIndex = maxZIndexCompare;
|
|
1728
1736
|
}
|
|
1729
1737
|
return {
|
|
1730
1738
|
node: maxZIndexNode,
|
|
1731
1739
|
zIndex: zIndex,
|
|
1732
1740
|
};
|
|
1733
1741
|
},
|
|
1734
|
-
/**
|
|
1735
|
-
* 获取页面中最大的z-index
|
|
1736
|
-
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
1737
|
-
* @example
|
|
1738
|
-
* Utils.getMaxZIndex();
|
|
1739
|
-
* > 1001
|
|
1740
|
-
**/
|
|
1741
|
-
getMaxZIndex(deviation = 1) {
|
|
1742
|
-
return this.getMaxZIndexNodeInfo(deviation).zIndex;
|
|
1743
|
-
},
|
|
1744
1742
|
/**
|
|
1745
1743
|
* 获取pops所有弹窗中的最大的z-index
|
|
1746
1744
|
* @param deviation
|
|
1747
1745
|
*/
|
|
1748
1746
|
getPopsMaxZIndex(deviation = 1) {
|
|
1749
1747
|
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
1750
|
-
// 最大值2147483647
|
|
1751
|
-
|
|
1748
|
+
// 最大值 2147483647
|
|
1749
|
+
// 最大值 2147483647
|
|
1750
|
+
// const maxZIndex = Math.pow(2, 31) - 1;
|
|
1751
|
+
// 比较值 2000000000
|
|
1752
|
+
const maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
1752
1753
|
// 当前页面最大的z-index
|
|
1753
1754
|
let zIndex = 0;
|
|
1754
1755
|
// 当前的最大z-index的元素,调试使用
|
|
1755
1756
|
let maxZIndexNode = null;
|
|
1757
|
+
/**
|
|
1758
|
+
* 元素是否可见
|
|
1759
|
+
* @param $css
|
|
1760
|
+
*/
|
|
1761
|
+
function isVisibleNode($css) {
|
|
1762
|
+
return $css.position !== "static" && $css.display !== "none";
|
|
1763
|
+
}
|
|
1756
1764
|
Object.keys(pops.config.layer).forEach((layerName) => {
|
|
1757
1765
|
let layerList = pops.config.layer[layerName];
|
|
1758
1766
|
for (let index = 0; index < layerList.length; index++) {
|
|
1759
1767
|
const layer = layerList[index];
|
|
1760
1768
|
let nodeStyle = window.getComputedStyle(layer.animElement);
|
|
1761
1769
|
/* 不对position为static和display为none的元素进行获取它们的z-index */
|
|
1762
|
-
if (nodeStyle
|
|
1770
|
+
if (isVisibleNode(nodeStyle)) {
|
|
1763
1771
|
let nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
1764
1772
|
if (!isNaN(nodeZIndex)) {
|
|
1765
1773
|
if (nodeZIndex > zIndex) {
|
|
@@ -1771,14 +1779,22 @@ var pops = (function () {
|
|
|
1771
1779
|
}
|
|
1772
1780
|
});
|
|
1773
1781
|
zIndex += deviation;
|
|
1774
|
-
// 用于比较的值2000000000,大于该值就取该值
|
|
1775
|
-
let maxZIndexCompare = 2 * Math.pow(10, 9);
|
|
1776
1782
|
if (zIndex >= maxZIndexCompare) {
|
|
1777
1783
|
// 最好不要超过最大值
|
|
1778
|
-
zIndex =
|
|
1784
|
+
zIndex = maxZIndexCompare;
|
|
1779
1785
|
}
|
|
1780
1786
|
return { zIndex: zIndex, animElement: maxZIndexNode };
|
|
1781
1787
|
},
|
|
1788
|
+
/**
|
|
1789
|
+
* 获取页面中最大的z-index
|
|
1790
|
+
* @param deviation 获取最大的z-index值的偏移,默认是+1
|
|
1791
|
+
* @example
|
|
1792
|
+
* Utils.getMaxZIndex();
|
|
1793
|
+
* > 1001
|
|
1794
|
+
**/
|
|
1795
|
+
getMaxZIndex(deviation = 1) {
|
|
1796
|
+
return this.getMaxZIndexNodeInfo(deviation).zIndex;
|
|
1797
|
+
},
|
|
1782
1798
|
/**
|
|
1783
1799
|
* 获取CSS Rule
|
|
1784
1800
|
* @param sheet
|
|
@@ -2762,6 +2778,8 @@ var pops = (function () {
|
|
|
2762
2778
|
},
|
|
2763
2779
|
/**
|
|
2764
2780
|
* 处理遮罩层
|
|
2781
|
+
*
|
|
2782
|
+
* + 设置遮罩层的点击事件
|
|
2765
2783
|
* @param details 传递的配置
|
|
2766
2784
|
*/
|
|
2767
2785
|
handleMask(details = {}) {
|
|
@@ -2795,22 +2813,29 @@ var pops = (function () {
|
|
|
2795
2813
|
}
|
|
2796
2814
|
return false;
|
|
2797
2815
|
}
|
|
2798
|
-
|
|
2799
|
-
return Boolean(element?.localName?.toLowerCase() === "div" &&
|
|
2800
|
-
element.className &&
|
|
2801
|
-
element.className === "pops-anim" &&
|
|
2802
|
-
element.hasAttribute("anim"));
|
|
2803
|
-
}
|
|
2816
|
+
// 判断是否启用了遮罩层点击动作
|
|
2804
2817
|
if (details.config.mask.clickEvent.toClose ||
|
|
2805
2818
|
details.config.mask.clickEvent.toHide) {
|
|
2819
|
+
/**
|
|
2820
|
+
* 判断点击的元素是否是动画层的元素
|
|
2821
|
+
* @param element
|
|
2822
|
+
* @returns
|
|
2823
|
+
*/
|
|
2824
|
+
function isAnimElement(element) {
|
|
2825
|
+
return Boolean(element?.localName?.toLowerCase() === "div" &&
|
|
2826
|
+
element.className &&
|
|
2827
|
+
element.className === "pops-anim" &&
|
|
2828
|
+
element.hasAttribute("anim"));
|
|
2829
|
+
}
|
|
2806
2830
|
/* 判断按下的元素是否是pops-anim */
|
|
2807
2831
|
popsDOMUtils.on(details.animElement, ["touchstart", "mousedown"], void 0, (event) => {
|
|
2808
|
-
|
|
2832
|
+
let $click = event.composedPath()[0];
|
|
2833
|
+
isMaskClick = isAnimElement($click);
|
|
2809
2834
|
});
|
|
2810
2835
|
/* 如果有动画层,在动画层上监听点击事件 */
|
|
2811
2836
|
popsDOMUtils.on(details.animElement, "click", void 0, (event) => {
|
|
2812
|
-
|
|
2813
|
-
|
|
2837
|
+
let $click = event.composedPath()[0];
|
|
2838
|
+
if (isAnimElement($click) && isMaskClick) {
|
|
2814
2839
|
return clickEvent(event);
|
|
2815
2840
|
}
|
|
2816
2841
|
});
|
|
@@ -2825,7 +2850,7 @@ var pops = (function () {
|
|
|
2825
2850
|
},
|
|
2826
2851
|
/**
|
|
2827
2852
|
* 处理获取元素
|
|
2828
|
-
* @param
|
|
2853
|
+
* @param animElement
|
|
2829
2854
|
* @param type
|
|
2830
2855
|
*/
|
|
2831
2856
|
handleQueryElement(animElement, type) {
|
|
@@ -8224,25 +8249,25 @@ var pops = (function () {
|
|
|
8224
8249
|
/**
|
|
8225
8250
|
* 已创建的元素列表
|
|
8226
8251
|
*/
|
|
8227
|
-
let
|
|
8252
|
+
let isCreatedElementList = [$anim];
|
|
8228
8253
|
/* 遮罩层元素 */
|
|
8229
8254
|
if (config.mask.enable) {
|
|
8230
|
-
let
|
|
8255
|
+
let { maskElement } = PopsHandler.handleMask({
|
|
8231
8256
|
type: PopsType,
|
|
8232
8257
|
guid: guid,
|
|
8233
8258
|
config: config,
|
|
8234
8259
|
animElement: $anim,
|
|
8235
8260
|
maskHTML: maskHTML,
|
|
8236
8261
|
});
|
|
8237
|
-
$mask =
|
|
8238
|
-
|
|
8262
|
+
$mask = maskElement;
|
|
8263
|
+
isCreatedElementList.push($mask);
|
|
8239
8264
|
}
|
|
8240
8265
|
/* 处理返回的配置 */
|
|
8241
8266
|
let eventDetails = PopsHandler.handleEventDetails(guid, $shadowContainer, $shadowRoot, PopsType, $anim, $pops, $mask, config);
|
|
8242
8267
|
/* 为顶部右边的关闭按钮添加点击事件 */
|
|
8243
8268
|
PopsHandler.handleClickEvent("close", $headerCloseBtn, eventDetails, config.btn.close.callback);
|
|
8244
8269
|
/* 创建到页面中 */
|
|
8245
|
-
popsDOMUtils.append($shadowRoot,
|
|
8270
|
+
popsDOMUtils.append($shadowRoot, isCreatedElementList);
|
|
8246
8271
|
if (typeof config.beforeAppendToPageCallBack === "function") {
|
|
8247
8272
|
config.beforeAppendToPageCallBack($shadowRoot, $shadowContainer);
|
|
8248
8273
|
}
|