@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.iife.js
CHANGED
|
@@ -281,7 +281,7 @@ var DOMUtils = (function () {
|
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
284
|
-
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),
|
|
284
|
+
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
|
|
285
285
|
|
|
286
286
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
287
287
|
const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -481,6 +481,14 @@ var DOMUtils = (function () {
|
|
|
481
481
|
isNodeList($ele) {
|
|
482
482
|
return Array.isArray($ele) || $ele instanceof NodeList;
|
|
483
483
|
},
|
|
484
|
+
/** 获取 animationend 在各个浏览器的兼容名 */
|
|
485
|
+
getAnimationEndNameList() {
|
|
486
|
+
return ["webkitAnimationEnd", "mozAnimationEnd", "MSAnimationEnd", "oanimationend", "animationend"];
|
|
487
|
+
},
|
|
488
|
+
/** 获取 transitionend 在各个浏览器的兼容名 */
|
|
489
|
+
getTransitionEndNameList() {
|
|
490
|
+
return ["webkitTransitionEnd", "mozTransitionEnd", "MSTransitionEnd", "otransitionend", "transitionend"];
|
|
491
|
+
},
|
|
484
492
|
};
|
|
485
493
|
|
|
486
494
|
/* 数据 */
|
|
@@ -603,8 +611,7 @@ var DOMUtils = (function () {
|
|
|
603
611
|
: event.target;
|
|
604
612
|
let totalParent = elementItem;
|
|
605
613
|
if (DOMUtilsCommonUtils.isWin(totalParent)) {
|
|
606
|
-
if (totalParent ===
|
|
607
|
-
DOMUtilsContext.windowApi.document) {
|
|
614
|
+
if (totalParent === DOMUtilsContext.windowApi.document) {
|
|
608
615
|
totalParent = DOMUtilsContext.windowApi.document.documentElement;
|
|
609
616
|
}
|
|
610
617
|
}
|
|
@@ -672,8 +679,7 @@ var DOMUtils = (function () {
|
|
|
672
679
|
if (typeof currentParam === "boolean") {
|
|
673
680
|
option.capture = currentParam;
|
|
674
681
|
}
|
|
675
|
-
else if (typeof currentParam === "object" &&
|
|
676
|
-
"capture" in currentParam) {
|
|
682
|
+
else if (typeof currentParam === "object" && "capture" in currentParam) {
|
|
677
683
|
option.capture = currentParam.capture;
|
|
678
684
|
}
|
|
679
685
|
return option;
|
|
@@ -735,8 +741,7 @@ var DOMUtils = (function () {
|
|
|
735
741
|
// 目标函数、事件名
|
|
736
742
|
isRemoveAll = true;
|
|
737
743
|
}
|
|
738
|
-
else if ((args.length === 3 && typeof args[2] === "string") ||
|
|
739
|
-
Array.isArray(args[2])) {
|
|
744
|
+
else if ((args.length === 3 && typeof args[2] === "string") || Array.isArray(args[2])) {
|
|
740
745
|
// 目标函数、事件名、子元素选择器
|
|
741
746
|
isRemoveAll = true;
|
|
742
747
|
}
|
|
@@ -751,9 +756,7 @@ var DOMUtils = (function () {
|
|
|
751
756
|
for (let index = 0; index < handlers.length; index++) {
|
|
752
757
|
let handler = handlers[index];
|
|
753
758
|
let flag = true;
|
|
754
|
-
if (flag &&
|
|
755
|
-
listenerCallBack &&
|
|
756
|
-
handler.originCallBack !== listenerCallBack) {
|
|
759
|
+
if (flag && listenerCallBack && handler.originCallBack !== listenerCallBack) {
|
|
757
760
|
// callback不同
|
|
758
761
|
flag = false;
|
|
759
762
|
}
|
|
@@ -813,9 +816,7 @@ var DOMUtils = (function () {
|
|
|
813
816
|
return;
|
|
814
817
|
}
|
|
815
818
|
let elementEvents = elementItem[symbolEvents] || {};
|
|
816
|
-
let iterEventNameList = eventTypeList.length
|
|
817
|
-
? eventTypeList
|
|
818
|
-
: Object.keys(elementEvents);
|
|
819
|
+
let iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
|
|
819
820
|
iterEventNameList.forEach((eventName) => {
|
|
820
821
|
let handlers = elementEvents[eventName];
|
|
821
822
|
if (!handlers) {
|
|
@@ -852,8 +853,7 @@ var DOMUtils = (function () {
|
|
|
852
853
|
try {
|
|
853
854
|
if (DOMUtilsContext.windowApi.document.readyState === "complete" ||
|
|
854
855
|
(DOMUtilsContext.windowApi.document.readyState !== "loading" &&
|
|
855
|
-
!DOMUtilsContext.windowApi.document.documentElement
|
|
856
|
-
.doScroll)) {
|
|
856
|
+
!DOMUtilsContext.windowApi.document.documentElement.doScroll)) {
|
|
857
857
|
return true;
|
|
858
858
|
}
|
|
859
859
|
else {
|
|
@@ -1114,6 +1114,76 @@ var DOMUtils = (function () {
|
|
|
1114
1114
|
DOMUtilsContext.on(element, "mouseenter", null, handler, option);
|
|
1115
1115
|
DOMUtilsContext.on(element, "mouseleave", null, handler, option);
|
|
1116
1116
|
}
|
|
1117
|
+
/**
|
|
1118
|
+
* 当动画结束时触发事件
|
|
1119
|
+
* @param element 监听的元素
|
|
1120
|
+
* @param handler 触发的回调函数
|
|
1121
|
+
* @param option 配置项,这里默认配置once为true
|
|
1122
|
+
*/
|
|
1123
|
+
animationend(element, handler, option) {
|
|
1124
|
+
let DOMUtilsContext = this;
|
|
1125
|
+
if (typeof element === "string") {
|
|
1126
|
+
element = DOMUtilsContext.selector(element);
|
|
1127
|
+
}
|
|
1128
|
+
if (element == null) {
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
if (DOMUtilsCommonUtils.isNodeList(element)) {
|
|
1132
|
+
// 设置
|
|
1133
|
+
element.forEach(($ele) => {
|
|
1134
|
+
DOMUtilsContext.animationend($ele, handler, option);
|
|
1135
|
+
});
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
const defaultOption = {
|
|
1139
|
+
once: true,
|
|
1140
|
+
};
|
|
1141
|
+
Object.assign(defaultOption, option || {});
|
|
1142
|
+
const eventNameList = DOMUtilsCommonUtils.getAnimationEndNameList();
|
|
1143
|
+
DOMUtilsContext.on(element, eventNameList, null, handler, defaultOption);
|
|
1144
|
+
if (!defaultOption.once) {
|
|
1145
|
+
return {
|
|
1146
|
+
off() {
|
|
1147
|
+
DOMUtilsContext.off(element, eventNameList, null, handler, defaultOption);
|
|
1148
|
+
},
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* 当过渡结束时触发事件
|
|
1154
|
+
* @param element 监听的元素
|
|
1155
|
+
* @param handler 触发的回调函数
|
|
1156
|
+
* @param option 配置项,这里默认配置once为true
|
|
1157
|
+
*/
|
|
1158
|
+
transitionend(element, handler, option) {
|
|
1159
|
+
let DOMUtilsContext = this;
|
|
1160
|
+
if (typeof element === "string") {
|
|
1161
|
+
element = DOMUtilsContext.selector(element);
|
|
1162
|
+
}
|
|
1163
|
+
if (element == null) {
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
if (DOMUtilsCommonUtils.isNodeList(element)) {
|
|
1167
|
+
// 设置
|
|
1168
|
+
element.forEach(($ele) => {
|
|
1169
|
+
DOMUtilsContext.transitionend($ele, handler, option);
|
|
1170
|
+
});
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
const defaultOption = {
|
|
1174
|
+
once: true,
|
|
1175
|
+
};
|
|
1176
|
+
Object.assign(defaultOption, option || {});
|
|
1177
|
+
const eventNameList = DOMUtilsCommonUtils.getTransitionEndNameList();
|
|
1178
|
+
DOMUtilsContext.on(element, eventNameList, null, handler, defaultOption);
|
|
1179
|
+
if (!defaultOption.once) {
|
|
1180
|
+
return {
|
|
1181
|
+
off() {
|
|
1182
|
+
DOMUtilsContext.off(element, eventNameList, null, handler, defaultOption);
|
|
1183
|
+
},
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1117
1187
|
/**
|
|
1118
1188
|
* 当按键松开时触发事件
|
|
1119
1189
|
* keydown - > keypress - > keyup
|
|
@@ -1488,7 +1558,7 @@ var DOMUtils = (function () {
|
|
|
1488
1558
|
super(option);
|
|
1489
1559
|
}
|
|
1490
1560
|
/** 版本号 */
|
|
1491
|
-
version = "2025.
|
|
1561
|
+
version = "2025.8.11";
|
|
1492
1562
|
attr(element, attrName, attrValue) {
|
|
1493
1563
|
let DOMUtilsContext = this;
|
|
1494
1564
|
if (typeof element === "string") {
|
|
@@ -1582,15 +1652,7 @@ var DOMUtils = (function () {
|
|
|
1582
1652
|
* 把纯数字没有px的加上
|
|
1583
1653
|
*/
|
|
1584
1654
|
function handlePixe(propertyName, propertyValue) {
|
|
1585
|
-
let allowAddPixe = [
|
|
1586
|
-
"width",
|
|
1587
|
-
"height",
|
|
1588
|
-
"top",
|
|
1589
|
-
"left",
|
|
1590
|
-
"right",
|
|
1591
|
-
"bottom",
|
|
1592
|
-
"font-size",
|
|
1593
|
-
];
|
|
1655
|
+
let allowAddPixe = ["width", "height", "top", "left", "right", "bottom", "font-size"];
|
|
1594
1656
|
if (typeof propertyValue === "number") {
|
|
1595
1657
|
propertyValue = propertyValue.toString();
|
|
1596
1658
|
}
|
|
@@ -1632,8 +1694,7 @@ var DOMUtils = (function () {
|
|
|
1632
1694
|
return;
|
|
1633
1695
|
}
|
|
1634
1696
|
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1635
|
-
if (typeof propertyValue === "string" &&
|
|
1636
|
-
propertyValue.trim().endsWith("!important")) {
|
|
1697
|
+
if (typeof propertyValue === "string" && propertyValue.trim().endsWith("!important")) {
|
|
1637
1698
|
propertyValue = propertyValue
|
|
1638
1699
|
.trim()
|
|
1639
1700
|
.replace(/!important$/gi, "")
|
|
@@ -1647,9 +1708,7 @@ var DOMUtils = (function () {
|
|
|
1647
1708
|
};
|
|
1648
1709
|
if (typeof property === "string") {
|
|
1649
1710
|
if (value == null) {
|
|
1650
|
-
return DOMUtilsContext.windowApi.globalThis
|
|
1651
|
-
.getComputedStyle(element)
|
|
1652
|
-
.getPropertyValue(property);
|
|
1711
|
+
return DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue(property);
|
|
1653
1712
|
}
|
|
1654
1713
|
else {
|
|
1655
1714
|
setStyleProperty(property, value);
|
|
@@ -1752,12 +1811,8 @@ var DOMUtils = (function () {
|
|
|
1752
1811
|
return transformInfo;
|
|
1753
1812
|
}
|
|
1754
1813
|
let elementTransform = DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).transform;
|
|
1755
|
-
if (elementTransform != null &&
|
|
1756
|
-
|
|
1757
|
-
elementTransform !== "") {
|
|
1758
|
-
let elementTransformSplit = elementTransform
|
|
1759
|
-
.match(/\((.+)\)/)?.[1]
|
|
1760
|
-
.split(",");
|
|
1814
|
+
if (elementTransform != null && elementTransform !== "none" && elementTransform !== "") {
|
|
1815
|
+
let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
|
|
1761
1816
|
if (elementTransformSplit) {
|
|
1762
1817
|
transform_left = Math.abs(parseInt(elementTransformSplit[4]));
|
|
1763
1818
|
transform_top = Math.abs(parseInt(elementTransformSplit[5]));
|
|
@@ -1795,8 +1850,7 @@ var DOMUtils = (function () {
|
|
|
1795
1850
|
}
|
|
1796
1851
|
if (value == null) {
|
|
1797
1852
|
// 获取
|
|
1798
|
-
if (element.localName === "input" &&
|
|
1799
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1853
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1800
1854
|
return element.checked;
|
|
1801
1855
|
}
|
|
1802
1856
|
else {
|
|
@@ -1805,8 +1859,7 @@ var DOMUtils = (function () {
|
|
|
1805
1859
|
}
|
|
1806
1860
|
else {
|
|
1807
1861
|
// 设置
|
|
1808
|
-
if (element.localName === "input" &&
|
|
1809
|
-
(element.type === "checkbox" || element.type === "radio")) {
|
|
1862
|
+
if (element.localName === "input" && (element.type === "checkbox" || element.type === "radio")) {
|
|
1810
1863
|
element.checked = !!value;
|
|
1811
1864
|
}
|
|
1812
1865
|
else {
|
|
@@ -2060,7 +2113,15 @@ var DOMUtils = (function () {
|
|
|
2060
2113
|
}
|
|
2061
2114
|
function elementAppendChild(ele, text) {
|
|
2062
2115
|
if (typeof content === "string") {
|
|
2063
|
-
ele
|
|
2116
|
+
if (ele instanceof DocumentFragment) {
|
|
2117
|
+
if (typeof text === "string") {
|
|
2118
|
+
text = DOMUtilsContext.parseHTML(text, true, false);
|
|
2119
|
+
}
|
|
2120
|
+
ele.appendChild(text);
|
|
2121
|
+
}
|
|
2122
|
+
else {
|
|
2123
|
+
ele.insertAdjacentHTML("beforeend", DOMUtilsCommonUtils.getSafeHTML(text));
|
|
2124
|
+
}
|
|
2064
2125
|
}
|
|
2065
2126
|
else {
|
|
2066
2127
|
ele.appendChild(text);
|
|
@@ -2071,6 +2132,7 @@ var DOMUtils = (function () {
|
|
|
2071
2132
|
let fragment = DOMUtilsContext.windowApi.document.createDocumentFragment();
|
|
2072
2133
|
content.forEach((ele) => {
|
|
2073
2134
|
if (typeof ele === "string") {
|
|
2135
|
+
// 转为元素
|
|
2074
2136
|
ele = DOMUtilsContext.parseHTML(ele, true, false);
|
|
2075
2137
|
}
|
|
2076
2138
|
fragment.appendChild(ele);
|
|
@@ -2106,7 +2168,13 @@ var DOMUtils = (function () {
|
|
|
2106
2168
|
return;
|
|
2107
2169
|
}
|
|
2108
2170
|
if (typeof content === "string") {
|
|
2109
|
-
element
|
|
2171
|
+
if (element instanceof DocumentFragment) {
|
|
2172
|
+
content = DOMUtilsContext.parseHTML(content, true, false);
|
|
2173
|
+
element.prepend(content);
|
|
2174
|
+
}
|
|
2175
|
+
else {
|
|
2176
|
+
element.insertAdjacentHTML("afterbegin", DOMUtilsCommonUtils.getSafeHTML(content));
|
|
2177
|
+
}
|
|
2110
2178
|
}
|
|
2111
2179
|
else {
|
|
2112
2180
|
let $firstChild = element.firstChild;
|
|
@@ -2279,16 +2347,14 @@ var DOMUtils = (function () {
|
|
|
2279
2347
|
return;
|
|
2280
2348
|
}
|
|
2281
2349
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2282
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2283
|
-
.clientWidth;
|
|
2350
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientWidth;
|
|
2284
2351
|
}
|
|
2285
2352
|
if (element.nodeType === 9) {
|
|
2286
2353
|
/* Document文档节点 */
|
|
2287
2354
|
element = element;
|
|
2288
2355
|
return Math.max(element.body.scrollWidth, element.documentElement.scrollWidth, element.body.offsetWidth, element.documentElement.offsetWidth, element.documentElement.clientWidth);
|
|
2289
2356
|
}
|
|
2290
|
-
if (isShow ||
|
|
2291
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2357
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2292
2358
|
/* 已显示 */
|
|
2293
2359
|
/* 不从style中获取对应的宽度,因为可能使用了class定义了width !important */
|
|
2294
2360
|
element = element;
|
|
@@ -2323,8 +2389,7 @@ var DOMUtils = (function () {
|
|
|
2323
2389
|
height(element, isShow = false) {
|
|
2324
2390
|
let DOMUtilsContext = this;
|
|
2325
2391
|
if (DOMUtilsCommonUtils.isWin(element)) {
|
|
2326
|
-
return DOMUtilsContext.windowApi.window.document.documentElement
|
|
2327
|
-
.clientHeight;
|
|
2392
|
+
return DOMUtilsContext.windowApi.window.document.documentElement.clientHeight;
|
|
2328
2393
|
}
|
|
2329
2394
|
if (typeof element === "string") {
|
|
2330
2395
|
element = DOMUtilsContext.selector(element);
|
|
@@ -2338,8 +2403,7 @@ var DOMUtils = (function () {
|
|
|
2338
2403
|
/* Document文档节点 */
|
|
2339
2404
|
return Math.max(element.body.scrollHeight, element.documentElement.scrollHeight, element.body.offsetHeight, element.documentElement.offsetHeight, element.documentElement.clientHeight);
|
|
2340
2405
|
}
|
|
2341
|
-
if (isShow ||
|
|
2342
|
-
(!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2406
|
+
if (isShow || (!isShow && DOMUtilsCommonUtils.isShow(element))) {
|
|
2343
2407
|
element = element;
|
|
2344
2408
|
/* 已显示 */
|
|
2345
2409
|
/* 从style中获取对应的高度,因为可能使用了class定义了width !important */
|
|
@@ -2467,8 +2531,7 @@ var DOMUtils = (function () {
|
|
|
2467
2531
|
let to = {};
|
|
2468
2532
|
for (let prop in styles) {
|
|
2469
2533
|
from[prop] =
|
|
2470
|
-
element.style[prop] ||
|
|
2471
|
-
DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2534
|
+
element.style[prop] || DOMUtilsContext.windowApi.globalThis.getComputedStyle(element)[prop];
|
|
2472
2535
|
to[prop] = styles[prop];
|
|
2473
2536
|
}
|
|
2474
2537
|
let timer = DOMUtilsCommonUtils.setInterval(function () {
|
|
@@ -2478,8 +2541,7 @@ var DOMUtils = (function () {
|
|
|
2478
2541
|
progress = 1;
|
|
2479
2542
|
}
|
|
2480
2543
|
for (let prop in styles) {
|
|
2481
|
-
element.style[prop] =
|
|
2482
|
-
from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2544
|
+
element.style[prop] = from[prop] + (to[prop] - from[prop]) * progress + "px";
|
|
2483
2545
|
}
|
|
2484
2546
|
if (progress === 1) {
|
|
2485
2547
|
DOMUtilsCommonUtils.clearInterval(timer);
|
|
@@ -2564,8 +2626,7 @@ var DOMUtils = (function () {
|
|
|
2564
2626
|
if (element == null) {
|
|
2565
2627
|
return;
|
|
2566
2628
|
}
|
|
2567
|
-
return Array.from(element.parentElement
|
|
2568
|
-
.children).filter((child) => child !== element);
|
|
2629
|
+
return Array.from(element.parentElement.children).filter((child) => child !== element);
|
|
2569
2630
|
}
|
|
2570
2631
|
/**
|
|
2571
2632
|
* 获取当前元素的父元素
|
|
@@ -2641,14 +2702,7 @@ var DOMUtils = (function () {
|
|
|
2641
2702
|
if (element.name &&
|
|
2642
2703
|
!element.disabled &&
|
|
2643
2704
|
(element.checked ||
|
|
2644
|
-
[
|
|
2645
|
-
"text",
|
|
2646
|
-
"hidden",
|
|
2647
|
-
"password",
|
|
2648
|
-
"textarea",
|
|
2649
|
-
"select-one",
|
|
2650
|
-
"select-multiple",
|
|
2651
|
-
].includes(element.type))) {
|
|
2705
|
+
["text", "hidden", "password", "textarea", "select-one", "select-multiple"].includes(element.type))) {
|
|
2652
2706
|
if (element.type === "select-multiple") {
|
|
2653
2707
|
for (let j = 0; j < element.options.length; j++) {
|
|
2654
2708
|
if (element.options[j].selected) {
|
|
@@ -2868,9 +2922,7 @@ var DOMUtils = (function () {
|
|
|
2868
2922
|
});
|
|
2869
2923
|
return;
|
|
2870
2924
|
}
|
|
2871
|
-
if (DOMUtilsContext.windowApi.globalThis
|
|
2872
|
-
.getComputedStyle(element)
|
|
2873
|
-
.getPropertyValue("display") === "none") {
|
|
2925
|
+
if (DOMUtilsContext.windowApi.globalThis.getComputedStyle(element).getPropertyValue("display") === "none") {
|
|
2874
2926
|
DOMUtilsContext.show(element, checkVisiblie);
|
|
2875
2927
|
}
|
|
2876
2928
|
else {
|
|
@@ -2915,9 +2967,7 @@ var DOMUtils = (function () {
|
|
|
2915
2967
|
selectionStart = Math.min($input.value.length, selectionStart);
|
|
2916
2968
|
if (typeof selectionEnd == "string")
|
|
2917
2969
|
selectionEnd = parseFloat(selectionEnd);
|
|
2918
|
-
if (typeof selectionEnd != "number" ||
|
|
2919
|
-
isNaN(selectionEnd) ||
|
|
2920
|
-
selectionEnd < selectionStart) {
|
|
2970
|
+
if (typeof selectionEnd != "number" || isNaN(selectionEnd) || selectionEnd < selectionStart) {
|
|
2921
2971
|
selectionEnd = selectionStart;
|
|
2922
2972
|
}
|
|
2923
2973
|
if (selectionEnd < 0)
|
|
@@ -3004,11 +3054,7 @@ var DOMUtils = (function () {
|
|
|
3004
3054
|
var isBoxModel = $box.offsetWidth == 2;
|
|
3005
3055
|
body.removeChild($box);
|
|
3006
3056
|
let $boxRect = $input.getBoundingClientRect();
|
|
3007
|
-
var clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, scrollTop = win.pageYOffset ||
|
|
3008
|
-
(isBoxModel && docElem.scrollTop) ||
|
|
3009
|
-
body.scrollTop, scrollLeft = win.pageXOffset ||
|
|
3010
|
-
(isBoxModel && docElem.scrollLeft) ||
|
|
3011
|
-
body.scrollLeft;
|
|
3057
|
+
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;
|
|
3012
3058
|
return {
|
|
3013
3059
|
top: $boxRect.top + scrollTop - clientTop,
|
|
3014
3060
|
left: $boxRect.left + scrollLeft - clientLeft,
|
|
@@ -3027,6 +3073,14 @@ var DOMUtils = (function () {
|
|
|
3027
3073
|
return isNumber ? parseFloat(val) : val;
|
|
3028
3074
|
}
|
|
3029
3075
|
}
|
|
3076
|
+
/** 获取 animationend 在各个浏览器的兼容名 */
|
|
3077
|
+
getAnimationEndNameList() {
|
|
3078
|
+
return DOMUtilsCommonUtils.getAnimationEndNameList();
|
|
3079
|
+
}
|
|
3080
|
+
/** 获取 transitionend 在各个浏览器的兼容名 */
|
|
3081
|
+
getTransitionEndNameList() {
|
|
3082
|
+
return DOMUtilsCommonUtils.getTransitionEndNameList();
|
|
3083
|
+
}
|
|
3030
3084
|
}
|
|
3031
3085
|
let domUtils = new DOMUtils();
|
|
3032
3086
|
|