@whitesev/pops 2.0.3 → 2.0.4
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 +138 -112
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +138 -112
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +138 -112
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +138 -112
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +138 -112
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +138 -112
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +3 -3
- package/dist/types/src/components/searchSuggestion/indexType.d.ts +1 -1
- package/dist/types/src/types/event.d.ts +3 -3
- package/dist/types/src/types/mask.d.ts +1 -1
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +3 -3
- package/package.json +1 -1
- package/src/Pops.ts +1 -1
- package/src/components/loading/index.ts +3 -0
- package/src/components/searchSuggestion/indexType.ts +1 -1
- package/src/handler/PopsHandler.ts +9 -11
- package/src/types/event.d.ts +3 -3
- package/src/types/mask.d.ts +1 -1
- package/src/utils/PopsDOMUtils.ts +21 -19
- package/src/utils/PopsInstanceUtils.ts +120 -96
package/dist/index.iife.js
CHANGED
|
@@ -1222,30 +1222,32 @@ var pops = (function () {
|
|
|
1222
1222
|
if (element == null) {
|
|
1223
1223
|
return;
|
|
1224
1224
|
}
|
|
1225
|
+
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1226
|
+
if (typeof propertyValue === "string" &&
|
|
1227
|
+
propertyValue.trim().endsWith("!important")) {
|
|
1228
|
+
propertyValue = propertyValue
|
|
1229
|
+
.trim()
|
|
1230
|
+
.replace(/!important$/gi, "")
|
|
1231
|
+
.trim();
|
|
1232
|
+
element.style.setProperty(propertyName, propertyValue, "important");
|
|
1233
|
+
}
|
|
1234
|
+
else {
|
|
1235
|
+
propertyValue = handlePixe(propertyName, propertyValue);
|
|
1236
|
+
element.style.setProperty(propertyName, propertyValue);
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1225
1239
|
if (typeof property === "string") {
|
|
1226
1240
|
if (value == null) {
|
|
1227
1241
|
return getComputedStyle(element).getPropertyValue(property);
|
|
1228
1242
|
}
|
|
1229
1243
|
else {
|
|
1230
|
-
|
|
1231
|
-
element.style.setProperty(property, value, "important");
|
|
1232
|
-
}
|
|
1233
|
-
else {
|
|
1234
|
-
value = handlePixe(property, value);
|
|
1235
|
-
element.style.setProperty(property, value);
|
|
1236
|
-
}
|
|
1244
|
+
setStyleProperty(property, value);
|
|
1237
1245
|
}
|
|
1238
1246
|
}
|
|
1239
1247
|
else if (typeof property === "object") {
|
|
1240
1248
|
for (let prop in property) {
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
element.style.setProperty(prop, property[prop], "important");
|
|
1244
|
-
}
|
|
1245
|
-
else {
|
|
1246
|
-
property[prop] = handlePixe(prop, property[prop]);
|
|
1247
|
-
element.style.setProperty(prop, property[prop]);
|
|
1248
|
-
}
|
|
1249
|
+
let value = property[prop];
|
|
1250
|
+
setStyleProperty(prop, value);
|
|
1249
1251
|
}
|
|
1250
1252
|
}
|
|
1251
1253
|
}
|
|
@@ -1904,31 +1906,37 @@ var pops = (function () {
|
|
|
1904
1906
|
* @param maskElement
|
|
1905
1907
|
*/
|
|
1906
1908
|
hide(popsType, layerConfigList, guid, config, animElement, maskElement) {
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1909
|
+
return new Promise((resolve) => {
|
|
1910
|
+
let popsElement = animElement.querySelector(".pops[type-value]");
|
|
1911
|
+
if (popsType === "drawer") {
|
|
1912
|
+
let drawerConfig = config;
|
|
1913
|
+
setTimeout(() => {
|
|
1914
|
+
maskElement.style.setProperty("display", "none");
|
|
1915
|
+
if (["top", "bottom"].includes(drawerConfig.direction)) {
|
|
1916
|
+
popsElement.style.setProperty("height", "0");
|
|
1917
|
+
}
|
|
1918
|
+
else if (["left", "right"].includes(drawerConfig.direction)) {
|
|
1919
|
+
popsElement.style.setProperty("width", "0");
|
|
1920
|
+
}
|
|
1921
|
+
else {
|
|
1922
|
+
console.error("未知direction:", drawerConfig.direction);
|
|
1923
|
+
}
|
|
1924
|
+
resolve();
|
|
1925
|
+
}, drawerConfig.closeDelay);
|
|
1926
|
+
}
|
|
1927
|
+
else {
|
|
1928
|
+
let findLayerIns = layerConfigList.find((layerConfigItem) => layerConfigItem.guid === guid);
|
|
1929
|
+
if (findLayerIns) {
|
|
1926
1930
|
/* 存在动画 */
|
|
1931
|
+
let layerConfigItem = findLayerIns;
|
|
1927
1932
|
layerConfigItem.animElement.style.width = "100%";
|
|
1928
1933
|
layerConfigItem.animElement.style.height = "100%";
|
|
1929
1934
|
layerConfigItem.animElement.style["animation-name"] =
|
|
1930
1935
|
layerConfigItem.animElement.getAttribute("anim") + "-reverse";
|
|
1931
1936
|
if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.style["animation-name"])) {
|
|
1937
|
+
/**
|
|
1938
|
+
* 动画结束的回调
|
|
1939
|
+
*/
|
|
1932
1940
|
function animationendCallBack() {
|
|
1933
1941
|
layerConfigItem.animElement.style.display = "none";
|
|
1934
1942
|
if (layerConfigItem.maskElement) {
|
|
@@ -1937,6 +1945,7 @@ var pops = (function () {
|
|
|
1937
1945
|
popsDOMUtils.off(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
1938
1946
|
capture: true,
|
|
1939
1947
|
});
|
|
1948
|
+
resolve();
|
|
1940
1949
|
}
|
|
1941
1950
|
popsDOMUtils.on(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
1942
1951
|
capture: true,
|
|
@@ -1947,11 +1956,11 @@ var pops = (function () {
|
|
|
1947
1956
|
if (layerConfigItem.maskElement) {
|
|
1948
1957
|
layerConfigItem.maskElement.style.display = "none";
|
|
1949
1958
|
}
|
|
1959
|
+
resolve();
|
|
1950
1960
|
}
|
|
1951
|
-
return;
|
|
1952
1961
|
}
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1955
1964
|
},
|
|
1956
1965
|
/**
|
|
1957
1966
|
* 显示
|
|
@@ -1963,27 +1972,30 @@ var pops = (function () {
|
|
|
1963
1972
|
* @param maskElement
|
|
1964
1973
|
*/
|
|
1965
1974
|
show(popsType, layerConfigList, guid, config, animElement, maskElement) {
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1975
|
+
return new Promise((resolve) => {
|
|
1976
|
+
let popsElement = animElement.querySelector(".pops[type-value]");
|
|
1977
|
+
if (popsType === "drawer") {
|
|
1978
|
+
let drawerConfig = config;
|
|
1979
|
+
setTimeout(() => {
|
|
1980
|
+
popsDOMUtils.css(maskElement, "display", "");
|
|
1981
|
+
let direction = drawerConfig.direction;
|
|
1982
|
+
let size = drawerConfig.size.toString();
|
|
1983
|
+
if (["top", "bottom"].includes(direction)) {
|
|
1984
|
+
popsElement.style.setProperty("height", size);
|
|
1985
|
+
}
|
|
1986
|
+
else if (["left", "right"].includes(direction)) {
|
|
1987
|
+
popsElement.style.setProperty("width", size);
|
|
1988
|
+
}
|
|
1989
|
+
else {
|
|
1990
|
+
console.error("未知direction:", direction);
|
|
1991
|
+
}
|
|
1992
|
+
resolve();
|
|
1993
|
+
}, drawerConfig.openDelay);
|
|
1994
|
+
}
|
|
1995
|
+
else {
|
|
1996
|
+
let findLayerIns = layerConfigList.find((layerConfigItem) => layerConfigItem.guid === guid);
|
|
1997
|
+
if (findLayerIns) {
|
|
1998
|
+
let layerConfigItem = findLayerIns;
|
|
1987
1999
|
layerConfigItem.animElement.style.width = "";
|
|
1988
2000
|
layerConfigItem.animElement.style.height = "";
|
|
1989
2001
|
layerConfigItem.animElement.style["animation-name"] =
|
|
@@ -1991,14 +2003,18 @@ var pops = (function () {
|
|
|
1991
2003
|
.animElement.getAttribute("anim")
|
|
1992
2004
|
.replace("-reverse", "");
|
|
1993
2005
|
if (pops.config.animation.hasOwnProperty(layerConfigItem.animElement.style["animation-name"])) {
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
}
|
|
2006
|
+
/**
|
|
2007
|
+
* 动画结束的回调
|
|
2008
|
+
*/
|
|
1998
2009
|
function animationendCallBack() {
|
|
1999
2010
|
popsDOMUtils.off(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
2000
2011
|
capture: true,
|
|
2001
2012
|
});
|
|
2013
|
+
resolve();
|
|
2014
|
+
}
|
|
2015
|
+
layerConfigItem.animElement.style.display = "";
|
|
2016
|
+
if (layerConfigItem.maskElement) {
|
|
2017
|
+
layerConfigItem.maskElement.style.display = "";
|
|
2002
2018
|
}
|
|
2003
2019
|
popsDOMUtils.on(layerConfigItem.animElement, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
2004
2020
|
capture: true,
|
|
@@ -2009,11 +2025,11 @@ var pops = (function () {
|
|
|
2009
2025
|
if (layerConfigItem.maskElement) {
|
|
2010
2026
|
layerConfigItem.maskElement.style.display = "";
|
|
2011
2027
|
}
|
|
2028
|
+
resolve();
|
|
2012
2029
|
}
|
|
2013
2030
|
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
}
|
|
2031
|
+
}
|
|
2032
|
+
});
|
|
2017
2033
|
},
|
|
2018
2034
|
/**
|
|
2019
2035
|
* 关闭
|
|
@@ -2024,50 +2040,57 @@ var pops = (function () {
|
|
|
2024
2040
|
* @param animElement
|
|
2025
2041
|
*/
|
|
2026
2042
|
close(popsType, layerConfigList, guid, config, animElement) {
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
function
|
|
2034
|
-
|
|
2043
|
+
return new Promise((resolve) => {
|
|
2044
|
+
let popsElement = animElement.querySelector(".pops[type-value]");
|
|
2045
|
+
let drawerConfig = config;
|
|
2046
|
+
/**
|
|
2047
|
+
* 动画结束事件
|
|
2048
|
+
*/
|
|
2049
|
+
function transitionendEvent() {
|
|
2050
|
+
/**
|
|
2051
|
+
* 弹窗已关闭的回调
|
|
2052
|
+
*/
|
|
2053
|
+
function closeCallBack(event) {
|
|
2054
|
+
if (event.propertyName !== "transform") {
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2057
|
+
popsDOMUtils.off(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, closeCallBack);
|
|
2058
|
+
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
2059
|
+
resolve();
|
|
2060
|
+
}
|
|
2061
|
+
/* 监听过渡结束 */
|
|
2062
|
+
popsDOMUtils.on(popsElement, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
|
|
2063
|
+
let popsTransForm = getComputedStyle(popsElement).transform;
|
|
2064
|
+
if (popsTransForm !== "none") {
|
|
2065
|
+
popsDOMUtils.trigger(popsElement, popsDOMUtils.getTransitionEndNameList(), void 0, true);
|
|
2035
2066
|
return;
|
|
2036
2067
|
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
}
|
|
2053
|
-
else if (["left"].includes(drawerConfig.direction)) {
|
|
2054
|
-
popsElement.style.setProperty("transform", "translateX(-100%)");
|
|
2068
|
+
if (["top"].includes(drawerConfig.direction)) {
|
|
2069
|
+
popsElement.style.setProperty("transform", "translateY(-100%)");
|
|
2070
|
+
}
|
|
2071
|
+
else if (["bottom"].includes(drawerConfig.direction)) {
|
|
2072
|
+
popsElement.style.setProperty("transform", "translateY(100%)");
|
|
2073
|
+
}
|
|
2074
|
+
else if (["left"].includes(drawerConfig.direction)) {
|
|
2075
|
+
popsElement.style.setProperty("transform", "translateX(-100%)");
|
|
2076
|
+
}
|
|
2077
|
+
else if (["right"].includes(drawerConfig.direction)) {
|
|
2078
|
+
popsElement.style.setProperty("transform", "translateX(100%)");
|
|
2079
|
+
}
|
|
2080
|
+
else {
|
|
2081
|
+
console.error("未知direction:", drawerConfig.direction);
|
|
2082
|
+
}
|
|
2055
2083
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2084
|
+
if (popsType === "drawer") {
|
|
2085
|
+
setTimeout(() => {
|
|
2086
|
+
transitionendEvent();
|
|
2087
|
+
}, drawerConfig.closeDelay);
|
|
2058
2088
|
}
|
|
2059
2089
|
else {
|
|
2060
|
-
|
|
2090
|
+
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
2091
|
+
resolve();
|
|
2061
2092
|
}
|
|
2062
|
-
}
|
|
2063
|
-
if (popsType === "drawer") {
|
|
2064
|
-
setTimeout(() => {
|
|
2065
|
-
transitionendEvent();
|
|
2066
|
-
}, drawerConfig.closeDelay);
|
|
2067
|
-
}
|
|
2068
|
-
else {
|
|
2069
|
-
PopsInstanceUtils.removeInstance([layerConfigList], guid);
|
|
2070
|
-
}
|
|
2093
|
+
});
|
|
2071
2094
|
},
|
|
2072
2095
|
/**
|
|
2073
2096
|
* 拖拽元素
|
|
@@ -2796,11 +2819,11 @@ var pops = (function () {
|
|
|
2796
2819
|
function originalRun() {
|
|
2797
2820
|
if (details.config.mask.clickEvent.toClose) {
|
|
2798
2821
|
/* 关闭 */
|
|
2799
|
-
PopsInstanceUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
|
|
2822
|
+
return PopsInstanceUtils.close(details.type, targetLayer, details.guid, details.config, details.animElement);
|
|
2800
2823
|
}
|
|
2801
2824
|
else if (details.config.mask.clickEvent.toHide) {
|
|
2802
2825
|
/* 隐藏 */
|
|
2803
|
-
PopsInstanceUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
|
|
2826
|
+
return PopsInstanceUtils.hide(details.type, targetLayer, details.guid, details.config, details.animElement, result.maskElement);
|
|
2804
2827
|
}
|
|
2805
2828
|
}
|
|
2806
2829
|
if (typeof details.config.mask.clickCallBack === "function") {
|
|
@@ -2979,13 +3002,13 @@ var pops = (function () {
|
|
|
2979
3002
|
mode: mode,
|
|
2980
3003
|
guid: guid,
|
|
2981
3004
|
close() {
|
|
2982
|
-
PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
3005
|
+
return PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
2983
3006
|
},
|
|
2984
3007
|
hide() {
|
|
2985
|
-
PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3008
|
+
return PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
2986
3009
|
},
|
|
2987
3010
|
show() {
|
|
2988
|
-
PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3011
|
+
return PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
2989
3012
|
},
|
|
2990
3013
|
};
|
|
2991
3014
|
},
|
|
@@ -3007,13 +3030,13 @@ var pops = (function () {
|
|
|
3007
3030
|
mode: mode,
|
|
3008
3031
|
guid: guid,
|
|
3009
3032
|
close() {
|
|
3010
|
-
PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
3033
|
+
return PopsInstanceUtils.close(mode, pops.config.layer[mode], guid, config, animElement);
|
|
3011
3034
|
},
|
|
3012
3035
|
hide() {
|
|
3013
|
-
PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3036
|
+
return PopsInstanceUtils.hide(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3014
3037
|
},
|
|
3015
3038
|
show() {
|
|
3016
|
-
PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3039
|
+
return PopsInstanceUtils.show(mode, pops.config.layer[mode], guid, config, animElement, maskElement);
|
|
3017
3040
|
},
|
|
3018
3041
|
};
|
|
3019
3042
|
},
|
|
@@ -3781,6 +3804,9 @@ var pops = (function () {
|
|
|
3781
3804
|
maskHTML: maskHTML,
|
|
3782
3805
|
});
|
|
3783
3806
|
$mask = _handleMask_.maskElement;
|
|
3807
|
+
// 遮罩层必须是跟随主内容
|
|
3808
|
+
// 即设置主内容position: relative,mask:position: absolute
|
|
3809
|
+
popsDOMUtils.css($mask, "position", "absolute !important");
|
|
3784
3810
|
elementList.push($mask);
|
|
3785
3811
|
}
|
|
3786
3812
|
let eventDetails = PopsHandler.handleLoadingEventDetails(guid, PopsType, $anim, $pops, $mask, config);
|
|
@@ -10055,7 +10081,7 @@ var pops = (function () {
|
|
|
10055
10081
|
/** 配置 */
|
|
10056
10082
|
config = {
|
|
10057
10083
|
/** 版本号 */
|
|
10058
|
-
version: "2025.5.
|
|
10084
|
+
version: "2025.5.12",
|
|
10059
10085
|
cssText: {
|
|
10060
10086
|
/** 主CSS */
|
|
10061
10087
|
index: indexCSS,
|