@whitesev/domutils 1.5.11 → 1.6.1
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 +129 -75
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +129 -75
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +129 -75
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +129 -75
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +129 -75
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +129 -75
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/DOMUtils.d.ts +16 -12
- package/dist/types/src/DOMUtilsCommonUtils.d.ts +4 -0
- package/dist/types/src/DOMUtilsEvent.d.ts +18 -0
- package/dist/types/src/types/DOMUtilsEvent.d.ts +2 -1
- package/package.json +5 -3
- package/src/DOMUtils.ts +98 -254
- package/src/DOMUtilsCommonUtils.ts +9 -4
- package/src/DOMUtilsData.ts +1 -3
- package/src/DOMUtilsEvent.ts +121 -178
- package/src/types/DOMUtilsEvent.d.ts +2 -1
package/dist/index.umd.js
CHANGED
|
@@ -284,7 +284,7 @@
|
|
|
284
284
|
};
|
|
285
285
|
|
|
286
286
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
287
|
-
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),
|
|
287
|
+
const worker = `(()=>{var e={455:function(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,(()=>{n(),t.close(),u.delete(o)})),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),l=(e,t,r=()=>!0)=>{const n=c(l,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},d=(e,t)=>r=>{const n=t.get(r);if(void 0===n)return Promise.resolve(!1);const[o,s]=n;return e(o),t.delete(r),s(!1),Promise.resolve(!0)},f=(e,t,r,n)=>(o,s,a)=>{const i=o+s-t.timeOrigin,u=i-t.now();return new Promise((t=>{e.set(a,[r(n,u,i,e,t,a),t])}))},m=new Map,h=d(globalThis.clearTimeout,m),p=new Map,v=d(globalThis.clearTimeout,p),w=((e,t)=>{const r=(n,o,s,a)=>{const i=n-e.now();i>0?o.set(a,[t(r,i,n,o,s,a),s]):(o.delete(a),s(!0))};return r})(performance,globalThis.setTimeout),g=f(m,performance,globalThis.setTimeout,w),T=f(p,performance,globalThis.setTimeout,w);l(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?h(e):v(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?g:T)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
|
|
288
288
|
|
|
289
289
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
290
290
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -484,6 +484,14 @@
|
|
|
484
484
|
isNodeList($ele) {
|
|
485
485
|
return Array.isArray($ele) || $ele instanceof NodeList;
|
|
486
486
|
},
|
|
487
|
+
/** 获取 animationend 在各个浏览器的兼容名 */
|
|
488
|
+
getAnimationEndNameList() {
|
|
489
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
490
|
+
},
|
|
491
|
+
/** 获取 transitionend 在各个浏览器的兼容名 */
|
|
492
|
+
getTransitionEndNameList() {
|
|
493
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
494
|
+
},
|
|
487
495
|
};
|
|
488
496
|
|
|
489
497
|
/* 数据 */
|
|
@@ -606,8 +614,7 @@
|
|
|
606
614
|
: event.target;
|
|
607
615
|
let totalParent = elementItem;
|
|
608
616
|
if (DOMUtilsCommonUtils.isWin(totalParent)) {
|
|
609
|
-
if (totalParent ===
|
|
610
|
-
DOMUtilsContext.windowApi.document) {
|
|
617
|
+
if (totalParent === DOMUtilsContext.windowApi.document) {
|
|
611
618
|
totalParent = DOMUtilsContext.windowApi.document.documentElement;
|
|
612
619
|
}
|
|
613
620
|
}
|
|
@@ -675,8 +682,7 @@
|
|
|
675
682
|
if (typeof currentParam === "boolean") {
|
|
676
683
|
option.capture = currentParam;
|
|
677
684
|
}
|
|
678
|
-
else if (typeof currentParam === "object" &&
|
|
679
|
-
"capture" in currentParam) {
|
|
685
|
+
else if (typeof currentParam === "object" && "capture" in currentParam) {
|
|
680
686
|
option.capture = currentParam.capture;
|
|
681
687
|
}
|
|
682
688
|
return option;
|
|
@@ -738,8 +744,7 @@
|
|
|
738
744
|
// 目标函数、事件名
|
|
739
745
|
isRemoveAll = true;
|
|
740
746
|
}
|
|
741
|
-
else if ((args.length === 3 && typeof args[2] === "string") ||
|
|
742
|
-
Array.isArray(args[2])) {
|
|
747
|
+
else if ((args.length === 3 && typeof args[2] === "string") || Array.isArray(args[2])) {
|
|
743
748
|
// 目标函数、事件名、子元素选择器
|
|
744
749
|
isRemoveAll = true;
|
|
745
750
|
}
|
|
@@ -754,9 +759,7 @@
|
|
|
754
759
|
for (let index = 0; index < handlers.length; index++) {
|
|
755
760
|
let handler = handlers[index];
|
|
756
761
|
let flag = true;
|
|
757
|
-
if (flag &&
|
|
758
|
-
listenerCallBack &&
|
|
759
|
-
handler.originCallBack !== listenerCallBack) {
|
|
762
|
+
if (flag && listenerCallBack && handler.originCallBack !== listenerCallBack) {
|
|
760
763
|
// callback不同
|
|
761
764
|
flag = false;
|
|
762
765
|
}
|
|
@@ -816,9 +819,7 @@
|
|
|
816
819
|
return;
|
|
817
820
|
}
|
|
818
821
|
let elementEvents = elementItem[symbolEvents] || {};
|
|
819
|
-
let iterEventNameList = eventTypeList.length
|
|
820
|
-
? eventTypeList
|
|
821
|
-
: Object.keys(elementEvents);
|
|
822
|
+
let iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
|
|
822
823
|
iterEventNameList.forEach((eventName) => {
|
|
823
824
|
let handlers = elementEvents[eventName];
|
|
824
825
|
if (!handlers) {
|
|
@@ -855,8 +856,7 @@
|
|
|
855
856
|
try {
|
|
856
857
|
if (DOMUtilsContext.windowApi.document.readyState === "complete" ||
|
|
857
858
|
(DOMUtilsContext.windowApi.document.readyState !== "loading" &&
|
|
858
|
-
!DOMUtilsContext.windowApi.document.documentElement
|
|
859
|
-
.doScroll)) {
|
|
859
|
+
!DOMUtilsContext.windowApi.document.documentElement.doScroll)) {
|
|
860
860
|
return true;
|
|
861
861
|
}
|
|
862
862
|
else {
|
|
@@ -1117,6 +1117,76 @@
|
|
|
1117
1117
|
DOMUtilsContext.on(element, "mouseenter", null, handler, option);
|
|
1118
1118
|
DOMUtilsContext.on(element, "mouseleave", null, handler, option);
|
|
1119
1119
|
}
|
|
1120
|
+
/**
|
|
1121
|
+
* 当动画结束时触发事件
|
|
1122
|
+
* @param element 监听的元素
|
|
1123
|
+
* @param handler 触发的回调函数
|
|
1124
|
+
* @param option 配置项,这里默认配置once为true
|
|
1125
|
+
*/
|
|
1126
|
+
animationend(element, handler, option) {
|
|
1127
|
+
let DOMUtilsContext = this;
|
|
1128
|
+
if (typeof element === "string") {
|
|
1129
|
+
element = DOMUtilsContext.selector(element);
|
|
1130
|
+
}
|
|
1131
|
+
if (element == null) {
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
if (DOMUtilsCommonUtils.isNodeList(element)) {
|
|
1135
|
+
// 设置
|
|
1136
|
+
element.forEach(($ele) => {
|
|
1137
|
+
DOMUtilsContext.animationend($ele, handler, option);
|
|
1138
|
+
});
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
const defaultOption = {
|
|
1142
|
+
once: true,
|
|
1143
|
+
};
|
|
1144
|
+
Object.assign(defaultOption, option || {});
|
|
1145
|
+
const eventNameList = DOMUtilsCommonUtils.getAnimationEndNameList();
|
|
1146
|
+
DOMUtilsContext.on(element, eventNameList, null, handler, defaultOption);
|
|
1147
|
+
if (!defaultOption.once) {
|
|
1148
|
+
return {
|
|
1149
|
+
off() {
|
|
1150
|
+
DOMUtilsContext.off(element, eventNameList, null, handler, defaultOption);
|
|
1151
|
+
},
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* 当过渡结束时触发事件
|
|
1157
|
+
* @param element 监听的元素
|
|
1158
|
+
* @param handler 触发的回调函数
|
|
1159
|
+
* @param option 配置项,这里默认配置once为true
|
|
1160
|
+
*/
|
|
1161
|
+
transitionend(element, handler, option) {
|
|
1162
|
+
let DOMUtilsContext = this;
|
|
1163
|
+
if (typeof element === "string") {
|
|
1164
|
+
element = DOMUtilsContext.selector(element);
|
|
1165
|
+
}
|
|
1166
|
+
if (element == null) {
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
if (DOMUtilsCommonUtils.isNodeList(element)) {
|
|
1170
|
+
// 设置
|
|
1171
|
+
element.forEach(($ele) => {
|
|
1172
|
+
DOMUtilsContext.transitionend($ele, handler, option);
|
|
1173
|
+
});
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
const defaultOption = {
|
|
1177
|
+
once: true,
|
|
1178
|
+
};
|
|
1179
|
+
Object.assign(defaultOption, option || {});
|
|
1180
|
+
const eventNameList = DOMUtilsCommonUtils.getTransitionEndNameList();
|
|
1181
|
+
DOMUtilsContext.on(element, eventNameList, null, handler, defaultOption);
|
|
1182
|
+
if (!defaultOption.once) {
|
|
1183
|
+
return {
|
|
1184
|
+
off() {
|
|
1185
|
+
DOMUtilsContext.off(element, eventNameList, null, handler, defaultOption);
|
|
1186
|
+
},
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1120
1190
|
/**
|
|
1121
1191
|
* 当按键松开时触发事件
|
|
1122
1192
|
* keydown - > keypress - > keyup
|
|
@@ -1491,7 +1561,7 @@
|
|
|
1491
1561
|
super(option);
|
|
1492
1562
|
}
|
|
1493
1563
|
/** 版本号 */
|
|
1494
|
-
version = "2025.
|
|
1564
|
+
version = "2025.8.11";
|
|
1495
1565
|
attr(element, attrName, attrValue) {
|
|
1496
1566
|
let DOMUtilsContext = this;
|
|
1497
1567
|
if (typeof element === "string") {
|
|
@@ -1585,15 +1655,7 @@
|
|
|
1585
1655
|
* 把纯数字没有px的加上
|
|
1586
1656
|
*/
|
|
1587
1657
|
function handlePixe(propertyName, propertyValue) {
|
|
1588
|
-
let allowAddPixe = [
|
|
1589
|
-
"width",
|
|
1590
|
-
"height",
|
|
1591
|
-
"top",
|
|
1592
|
-
"left",
|
|
1593
|
-
"right",
|
|
1594
|
-
"bottom",
|
|
1595
|
-
"font-size",
|
|
1596
|
-
];
|
|
1658
|
+
let allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
|
|
1597
1659
|
if (typeof propertyValue === "number") {
|
|
1598
1660
|
propertyValue = propertyValue.toString();
|
|
1599
1661
|
}
|
|
@@ -1635,8 +1697,7 @@
|
|
|
1635
1697
|
return;
|
|
1636
1698
|
}
|
|
1637
1699
|
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1638
|
-
if (typeof propertyValue === "string" &&
|
|
1639
|
-
propertyValue.trim().endsWith("!important")) {
|
|
1700
|
+
if (typeof propertyValue === "string" && propertyValue.trim().endsWith("!important")) {
|
|
1640
1701
|
propertyValue = propertyValue
|
|
1641
1702
|
.trim()
|
|
1642
1703
|
.replace(/!important$/gi, "")
|
|
@@ -1650,9 +1711,7 @@
|
|
|
1650
1711
|
};
|
|
1651
1712
|
if (typeof property === "string") {
|
|
1652
1713
|
if (value == null) {
|
|
1653
|
-
return DOMUtilsContext.windowApi.globalThis
|
|
1654
|
-
.getComputedStyle(element)
|
|
1655
|
-
.getPropertyValue(property);
|
|
1714
|
+
return DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue(property);
|
|
1656
1715
|
}
|
|
1657
1716
|
else {
|
|
1658
1717
|
setStyleProperty(property, value);
|
|
@@ -1755,12 +1814,8 @@
|
|
|
1755
1814
|
return transformInfo;
|
|
1756
1815
|
}
|
|
1757
1816
|
let elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
|
|
1758
|
-
if (elementTransform != null &&
|
|
1759
|
-
|
|
1760
|
-
elementTransform !== "") {
|
|
1761
|
-
let elementTransformSplit = elementTransform
|
|
1762
|
-
.match(/\((.+)\)/)?.[1]
|
|
1763
|
-
.split(",");
|
|
1817
|
+
if (elementTransform != null && elementTransform !== "none" && elementTransform !== "") {
|
|
1818
|
+
let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
|
|
1764
1819
|
if (elementTransformSplit) {
|
|
1765
1820
|
transform_left = Math.abs(parseInt(elementTransformSplit[4]));
|
|
1766
1821
|
transform_top = Math.abs(parseInt(elementTransformSplit[5]));
|
|
@@ -1798,8 +1853,7 @@
|
|
|
1798
1853
|
}
|
|
1799
1854
|
if (value == null) {
|
|
1800
1855
|
// 获取
|
|
1801
|
-
if (element.localName === "input" &&
|
|
1802
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1856
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1803
1857
|
return element.checked;
|
|
1804
1858
|
}
|
|
1805
1859
|
else {
|
|
@@ -1808,8 +1862,7 @@
|
|
|
1808
1862
|
}
|
|
1809
1863
|
else {
|
|
1810
1864
|
// 设置
|
|
1811
|
-
if (element.localName === "input" &&
|
|
1812
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1865
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1813
1866
|
element.checked = !!value;
|
|
1814
1867
|
}
|
|
1815
1868
|
else {
|
|
@@ -2063,7 +2116,15 @@
|
|
|
2063
2116
|
}
|
|
2064
2117
|
function elementAppendChild(ele, text) {
|
|
2065
2118
|
if (typeof content === "string") {
|
|
2066
|
-
ele
|
|
2119
|
+
if (ele instanceof DocumentFragment) {
|
|
2120
|
+
if (typeof text === "string") {
|
|
2121
|
+
text = DOMUtilsContext.parseHTML(text, true, false);
|
|
2122
|
+
}
|
|
2123
|
+
ele.appendChild(text);
|
|
2124
|
+
}
|
|
2125
|
+
else {
|
|
2126
|
+
ele.insertAdjacentHTML("beforeend", DOMUtilsCommonUtils.getSafeHTML(text));
|
|
2127
|
+
}
|
|
2067
2128
|
}
|
|
2068
2129
|
else {
|
|
2069
2130
|
ele.appendChild(text);
|
|
@@ -2074,6 +2135,7 @@
|
|
|
2074
2135
|
let fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
|
|
2075
2136
|
content.forEach((ele) => {
|
|
2076
2137
|
if (typeof ele === "string") {
|
|
2138
|
+
// 转为元素
|
|
2077
2139
|
ele = DOMUtilsContext.parseHTML(ele, true, false);
|
|
2078
2140
|
}
|
|
2079
2141
|
fragment.appendChild(ele);
|
|
@@ -2109,7 +2171,13 @@
|
|
|
2109
2171
|
return;
|
|
2110
2172
|
}
|
|
2111
2173
|
if (typeof content === "string") {
|
|
2112
|
-
element
|
|
2174
|
+
if (element instanceof DocumentFragment) {
|
|
2175
|
+
content = DOMUtilsContext.parseHTML(content, true, false);
|
|
2176
|
+
element.prepend(content);
|
|
2177
|
+
}
|
|
2178
|
+
else {
|
|
2179
|
+
element.insertAdjacentHTML("afterbegin", DOMUtilsCommonUtils.getSafeHTML(content));
|
|
2180
|
+
}
|
|
2113
2181
|
}
|
|
2114
2182
|
else {
|
|
2115
2183
|
let $firstChild = element.firstChild;
|
|
@@ -2282,16 +2350,14 @@
|
|
|
2282
2350
|
return;
|
|
2283
2351
|
}
|
|
2284
2352
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2285
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2286
|
-
.clientWidth;
|
|
2353
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientWidth;
|
|
2287
2354
|
}
|
|
2288
2355
|
if (element.nodeType === 9) {
|
|
2289
2356
|
/* Document文档节点 */
|
|
2290
2357
|
element = element;
|
|
2291
2358
|
return Math.max(element.body.scrollWidth, element.documentElement.scrollWidth, element.body.offsetWidth, element.documentElement.offsetWidth, element.documentElement.clientWidth);
|
|
2292
2359
|
}
|
|
2293
|
-
if (isShow ||
|
|
2294
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2360
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2295
2361
|
/* 已显示 */
|
|
2296
2362
|
/* 不从style中获取对应的宽度,因为可能使用了class定义了width !important */
|
|
2297
2363
|
element = element;
|
|
@@ -2326,8 +2392,7 @@
|
|
|
2326
2392
|
height(element, isShow = false) {
|
|
2327
2393
|
let DOMUtilsContext = this;
|
|
2328
2394
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2329
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2330
|
-
.clientHeight;
|
|
2395
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientHeight;
|
|
2331
2396
|
}
|
|
2332
2397
|
if (typeof element === "string") {
|
|
2333
2398
|
element = DOMUtilsContext.selector(element);
|
|
@@ -2341,8 +2406,7 @@
|
|
|
2341
2406
|
/* Document文档节点 */
|
|
2342
2407
|
return Math.max(element.body.scrollHeight, element.documentElement.scrollHeight, element.body.offsetHeight, element.documentElement.offsetHeight, element.documentElement.clientHeight);
|
|
2343
2408
|
}
|
|
2344
|
-
if (isShow ||
|
|
2345
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2409
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2346
2410
|
element = element;
|
|
2347
2411
|
/* 已显示 */
|
|
2348
2412
|
/* 从style中获取对应的高度,因为可能使用了class定义了width !important */
|
|
@@ -2470,8 +2534,7 @@
|
|
|
2470
2534
|
let to = {};
|
|
2471
2535
|
for (let prop in styles) {
|
|
2472
2536
|
from[prop] =
|
|
2473
|
-
element.style[prop] ||
|
|
2474
|
-
DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2537
|
+
element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2475
2538
|
to[prop] = styles[prop];
|
|
2476
2539
|
}
|
|
2477
2540
|
let timer = DOMUtilsCommonUtils.setInterval(function () {
|
|
@@ -2481,8 +2544,7 @@
|
|
|
2481
2544
|
progress = 1;
|
|
2482
2545
|
}
|
|
2483
2546
|
for (let prop in styles) {
|
|
2484
|
-
element.style[prop] =
|
|
2485
|
-
from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2547
|
+
element.style[prop] = from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2486
2548
|
}
|
|
2487
2549
|
if (progress === 1) {
|
|
2488
2550
|
DOMUtilsCommonUtils.clearInterval(timer);
|
|
@@ -2567,8 +2629,7 @@
|
|
|
2567
2629
|
if (element == null) {
|
|
2568
2630
|
return;
|
|
2569
2631
|
}
|
|
2570
|
-
return Array.from(element.parentElement
|
|
2571
|
-
.children).filter((child) => child !== element);
|
|
2632
|
+
return Array.from(element.parentElement.children).filter((child) => child !== element);
|
|
2572
2633
|
}
|
|
2573
2634
|
/**
|
|
2574
2635
|
* 获取当前元素的父元素
|
|
@@ -2644,14 +2705,7 @@
|
|
|
2644
2705
|
if (element.name &&
|
|
2645
2706
|
!element.disabled &&
|
|
2646
2707
|
(element.checked ||
|
|
2647
|
-
[
|
|
2648
|
-
"text",
|
|
2649
|
-
"hidden",
|
|
2650
|
-
"password",
|
|
2651
|
-
"textarea",
|
|
2652
|
-
"select-one",
|
|
2653
|
-
"select-multiple",
|
|
2654
|
-
].includes(element.type))) {
|
|
2708
|
+
["text", "hidden", "password", "textarea", "select-one", "select-multiple"].includes(element.type))) {
|
|
2655
2709
|
if (element.type === "select-multiple") {
|
|
2656
2710
|
for (let j = 0; j < element.options.length; j++) {
|
|
2657
2711
|
if (element.options[j].selected) {
|
|
@@ -2871,9 +2925,7 @@
|
|
|
2871
2925
|
});
|
|
2872
2926
|
return;
|
|
2873
2927
|
}
|
|
2874
|
-
if (DOMUtilsContext.windowApi.globalThis
|
|
2875
|
-
.getComputedStyle(element)
|
|
2876
|
-
.getPropertyValue("display") === "none") {
|
|
2928
|
+
if (DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue("display") === "none") {
|
|
2877
2929
|
DOMUtilsContext.show(element, checkVisiblie);
|
|
2878
2930
|
}
|
|
2879
2931
|
else {
|
|
@@ -2918,9 +2970,7 @@
|
|
|
2918
2970
|
selectionStart = Math.min($input.value.length, selectionStart);
|
|
2919
2971
|
if (typeof selectionEnd == "string")
|
|
2920
2972
|
selectionEnd = parseFloat(selectionEnd);
|
|
2921
|
-
if (typeof selectionEnd != "number" ||
|
|
2922
|
-
isNaN(selectionEnd) ||
|
|
2923
|
-
selectionEnd < selectionStart) {
|
|
2973
|
+
if (typeof selectionEnd != "number" || isNaN(selectionEnd) || selectionEnd < selectionStart) {
|
|
2924
2974
|
selectionEnd = selectionStart;
|
|
2925
2975
|
}
|
|
2926
2976
|
if (selectionEnd < 0)
|
|
@@ -3007,11 +3057,7 @@
|
|
|
3007
3057
|
var isBoxModel = $box.offsetWidth == 2;
|
|
3008
3058
|
body.removeChild($box);
|
|
3009
3059
|
let $boxRect = $input.getBoundingClientRect();
|
|
3010
|
-
var clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, scrollTop = win.pageYOffset ||
|
|
3011
|
-
(isBoxModel && docElem.scrollTop) ||
|
|
3012
|
-
body.scrollTop, scrollLeft = win.pageXOffset ||
|
|
3013
|
-
(isBoxModel && docElem.scrollLeft) ||
|
|
3014
|
-
body.scrollLeft;
|
|
3060
|
+
var clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, scrollTop = win.pageYOffset || (isBoxModel && docElem.scrollTop) || body.scrollTop, scrollLeft = win.pageXOffset || (isBoxModel && docElem.scrollLeft) || body.scrollLeft;
|
|
3015
3061
|
return {
|
|
3016
3062
|
top: $boxRect.top + scrollTop - clientTop,
|
|
3017
3063
|
left: $boxRect.left + scrollLeft - clientLeft,
|
|
@@ -3030,6 +3076,14 @@
|
|
|
3030
3076
|
return isNumber ? parseFloat(val) : val;
|
|
3031
3077
|
}
|
|
3032
3078
|
}
|
|
3079
|
+
/** 获取 animationend 在各个浏览器的兼容名 */
|
|
3080
|
+
getAnimationEndNameList() {
|
|
3081
|
+
return DOMUtilsCommonUtils.getAnimationEndNameList();
|
|
3082
|
+
}
|
|
3083
|
+
/** 获取 transitionend 在各个浏览器的兼容名 */
|
|
3084
|
+
getTransitionEndNameList() {
|
|
3085
|
+
return DOMUtilsCommonUtils.getTransitionEndNameList();
|
|
3086
|
+
}
|
|
3033
3087
|
}
|
|
3034
3088
|
let domUtils = new DOMUtils();
|
|
3035
3089
|
|