@danielgindi/dom-utils 1.0.9 → 1.0.10
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/lib.cjs.js +24 -25
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +3 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +24 -23
- package/dist/lib.es6.min.js +3 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +24 -25
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +3 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/package.json +11 -11
package/dist/lib.es6.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/dom-utils 1.0.
|
|
2
|
+
* @danielgindi/dom-utils 1.0.10
|
|
3
3
|
* git://github.com/danielgindi/dom-utils.git
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -422,19 +422,19 @@ const parseTransition = (transition) => {
|
|
|
422
422
|
|
|
423
423
|
var Css = /*#__PURE__*/Object.freeze({
|
|
424
424
|
__proto__: null,
|
|
425
|
+
anchoredPosition: anchoredPosition,
|
|
425
426
|
getCssProps: getCssProps,
|
|
426
|
-
setCssProps: setCssProps,
|
|
427
|
-
getElementWidth: getElementWidth,
|
|
428
427
|
getElementHeight: getElementHeight,
|
|
429
|
-
setElementWidth: setElementWidth,
|
|
430
|
-
setElementHeight: setElementHeight,
|
|
431
|
-
getPseudoElementWidth: getPseudoElementWidth,
|
|
432
|
-
getPseudoElementHeight: getPseudoElementHeight,
|
|
433
428
|
getElementOffset: getElementOffset,
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
429
|
+
getElementWidth: getElementWidth,
|
|
430
|
+
getPseudoElementHeight: getPseudoElementHeight,
|
|
431
|
+
getPseudoElementWidth: getPseudoElementWidth,
|
|
437
432
|
isTimeString: isTimeString,
|
|
433
|
+
parseSingleTransition: parseSingleTransition,
|
|
434
|
+
parseTransition: parseTransition,
|
|
435
|
+
setCssProps: setCssProps,
|
|
436
|
+
setElementHeight: setElementHeight,
|
|
437
|
+
setElementWidth: setElementWidth,
|
|
438
438
|
timeToMs: timeToMs
|
|
439
439
|
});
|
|
440
440
|
|
|
@@ -562,11 +562,11 @@ const unwrapChildren = function (el) {
|
|
|
562
562
|
|
|
563
563
|
var Dom = /*#__PURE__*/Object.freeze({
|
|
564
564
|
__proto__: null,
|
|
565
|
-
createElement: createElement,
|
|
566
|
-
setElementAttrs: setElementAttrs,
|
|
567
565
|
closestUntil: closestUntil,
|
|
568
|
-
|
|
566
|
+
createElement: createElement,
|
|
569
567
|
next: next,
|
|
568
|
+
prev: prev,
|
|
569
|
+
setElementAttrs: setElementAttrs,
|
|
570
570
|
unwrapChildren: unwrapChildren
|
|
571
571
|
});
|
|
572
572
|
|
|
@@ -836,13 +836,13 @@ const toggleClass = function (el, className, toggle) {
|
|
|
836
836
|
|
|
837
837
|
var DomCompat = /*#__PURE__*/Object.freeze({
|
|
838
838
|
__proto__: null,
|
|
839
|
-
getRootNode: getRootNode,
|
|
840
|
-
closest: closest,
|
|
841
|
-
remove: remove,
|
|
842
|
-
before: before,
|
|
843
839
|
after: after,
|
|
844
|
-
prepend: prepend,
|
|
845
840
|
append: append,
|
|
841
|
+
before: before,
|
|
842
|
+
closest: closest,
|
|
843
|
+
getRootNode: getRootNode,
|
|
844
|
+
prepend: prepend,
|
|
845
|
+
remove: remove,
|
|
846
846
|
scopedSelector: scopedSelector,
|
|
847
847
|
scopedSelectorAll: scopedSelectorAll,
|
|
848
848
|
toggleClass: toggleClass
|
|
@@ -919,7 +919,7 @@ class DomEventsSink {
|
|
|
919
919
|
|
|
920
920
|
var DomEventsSink$1 = /*#__PURE__*/Object.freeze({
|
|
921
921
|
__proto__: null,
|
|
922
|
-
|
|
922
|
+
default: DomEventsSink
|
|
923
923
|
});
|
|
924
924
|
|
|
925
925
|
/**
|
|
@@ -1160,14 +1160,15 @@ function setScrollHorz(el, horz, rtl) {
|
|
|
1160
1160
|
|
|
1161
1161
|
var ScrollHelper = /*#__PURE__*/Object.freeze({
|
|
1162
1162
|
__proto__: null,
|
|
1163
|
-
calculateNativeScrollLeftForLeft: calculateNativeScrollLeftForLeft,
|
|
1164
|
-
getScrollLeft: getScrollLeft,
|
|
1165
|
-
setScrollLeft: setScrollLeft,
|
|
1166
1163
|
calculateNativeScrollLeftForHorz: calculateNativeScrollLeftForHorz,
|
|
1164
|
+
calculateNativeScrollLeftForLeft: calculateNativeScrollLeftForLeft,
|
|
1167
1165
|
getScrollHorz: getScrollHorz,
|
|
1168
|
-
|
|
1166
|
+
getScrollLeft: getScrollLeft,
|
|
1167
|
+
setScrollHorz: setScrollHorz,
|
|
1168
|
+
setScrollLeft: setScrollLeft
|
|
1169
1169
|
});
|
|
1170
1170
|
|
|
1171
1171
|
export { Css, Dom, DomCompat, DomEventsSink$1 as DomEventsSink, ScrollHelper, Touches };
|
|
1172
|
+
//# sourceMappingURL=index.js.map
|
|
1172
1173
|
|
|
1173
1174
|
//# sourceMappingURL=lib.es6.js.map
|
package/dist/lib.es6.min.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/dom-utils 1.0.
|
|
2
|
+
* @danielgindi/dom-utils 1.0.10
|
|
3
3
|
* git://github.com/danielgindi/dom-utils.git
|
|
4
4
|
*/
|
|
5
|
-
const e=function(e,t){for(let[n,r]of Object.entries(t))e.style[n]=null==r?"":String(r)},t=function(e,t,n,r,o){return(...l)=>{let i,s,d,a,c=l[0];if(e?(i=l[1],s=!!l[2],d=!!l[3],a=!!l[4]):(s=!!l[1],d=!!l[2],a=!!l[3]),c===window)return c.document.documentElement[`client${n}`];if(9===c.nodeType){const e=c.documentElement,t=c.body;return Math.max(t[`scroll${n}`],e[`scroll${n}`],t[`offset${n}`],e[`offset${n}`],e[`client${n}`])}{let l,p,u=!1,f=!1;if(!e&&"getBoundingClientRect"in c&&(l=c.getBoundingClientRect()[t],u=!0,f=!0),(void 0===l||a||u!==s||f!==d)&&(p=e?getComputedStyle(c,i):getComputedStyle(c)),void 0===l){let e=p[t];"auto"===e?(l=c[`client${n}`],u=!0):l=parseFloat(e),"border-box"===p.boxSizing&&(u=!0,f=!0)}if(s!==u){let e=parseFloat(p[`padding-${r}`]||0)+parseFloat(p[`padding-${o}`]||0);s?l+=e:l-=e}if(d!==f){let e=parseFloat(p[`border-${r}-width`]||0)+parseFloat(p[`border-${o}-width`]||0);d?l+=e:l-=e}return l<0&&(l=0),a&&(l+=parseFloat(p[`margin-${r}`]||0)+parseFloat(p[`margin-${o}`]||0)),l}}},n=(e,t,n,r)=>(t,o,l=!1,i=!1,s=!1)=>{if(t===window)return;if(9===t.nodeType)return;const d=getComputedStyle(t);let a=!1;if("border-box"===d.boxSizing&&(a=!0),l=!!l,i=!!i,(s=!!s)&&(o-=(parseFloat(d[`margin-${n}`])||0)+(parseFloat(d[`margin-${r}`])||0)),l!==a){let e=parseFloat(d[`padding-${n}`]||0)+parseFloat(d[`padding-${r}`]||0);l?o-=e:o+=e}if(i!==a){let e=(parseFloat(d[`border-${n}-width`])||0)+(parseFloat(d[`border-${r}-width`])||0);i?o-=e:o+=e}o<0&&(o=0),t.style[e]=o+"px"},r=t(!1,"width","Width","left","right"),o=t(!1,"height","Height","top","bottom"),l=t(!0,"width","Width","left","right"),i=t(!0,"height","Height","top","bottom"),s=n("width",0,"left","right"),d=n("height",0,"top","bottom"),a=e=>{if(!e)return;let t=e.endsWith("ms");return parseFloat(e)*(t?1:1e3)},c=e=>/^-?(0?\.)?\d+m?s$/.test(e),p=e=>{let t=e.split(/\s+/),n=t[0],r=t[1],o=t[2],l=t[3];return c(o)?{delay:a(o),duration:a(r),name:n}:{delay:a(l),duration:a(r),name:n,timingFunction:o}};var u=Object.freeze({__proto__:null,getCssProps:function(e,t){const n=getComputedStyle(e);let r={};for(let o of t){let t=n[o];("width"===o||"height"===o)&&"auto"===t&&e instanceof HTMLElement&&(t=e["offset"+o.substr(0,1).toUpperCase()+o.substr(1)],"border-box"!==n.boxSizing&&("width"===o?(t-=parseFloat(n.paddingLeft||0),t-=parseFloat(n.paddingRight||0),t-=parseFloat(n.borderLeftWidth||0),t-=parseFloat(n.borderRightWidth||0)):(t-=parseFloat(n.paddingTop||0),t-=parseFloat(n.paddingBottom||0),t-=parseFloat(n.borderTopWidth||0),t-=parseFloat(n.borderBottomWidth||0)),t<0&&(t=0)),t+="px"),r[o]=t}return r},setCssProps:e,getElementWidth:r,getElementHeight:o,setElementWidth:s,setElementHeight:d,getPseudoElementWidth:l,getPseudoElementHeight:i,getElementOffset:e=>{if(!e.getClientRects().length)return{top:0,left:0};let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView;return{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}},anchoredPosition:function(e,t,n,o,l){let i,s,d,a;if(o||(o={width:r(e,!0,!0),height:r(e,!0,!0)}),"start"!==t&&"end"!==t||(null==l&&(l="rtl"===getComputedStyle(e).direction),t="start"===t?l?"right":"left":l?"left":"right"),"right"===t)i=o.width,d=0;else if("center"===t)i=o.width/2,d=i;else if("left"===t)i=0,d=o.width;else if(t&&"string"==typeof t&&"%"===t.charAt(t.length-1)){let n=(parseFloat(t)||0)/100;i=o.width*n,d=o.width*-n,null==l&&(l="rtl"===getComputedStyle(e).direction),l&&(i=o.width-i,d=o.width-i)}else i=parseFloat(t)||0,d=-i;if("bottom"===n)s=o.height,a=0;else if("center"===n)s=o.height/2,a=s;else if("top"===n)s=0,a=o.height;else if(n&&"string"==typeof n&&"%"===n.charAt(n.length-1)){let e=(parseFloat(n)||0)/100;s=o.height*e,a=o.height*-e}else s=parseFloat(n)||0,a=-s;return{left:i,top:s,right:d,bottom:a,xSpec:t,ySpec:n}},parseTransition:e=>e?(e.match(/([^,()]|\([^)]*\))+/g)??[]).map((e=>e.trim())).filter((e=>e.length>0)).map(p):[],parseSingleTransition:p,isTimeString:c,timeToMs:a});const f=function(t,n){for(let[r,o]of Object.entries(n))null!=o&&("innerHTML"===r?t.innerHTML=String(o):"css"===r&&"style"in t?e(t,o):r in t&&"style"!==r?t[r]=o:t.setAttribute(r,String(o)))};var h=Object.freeze({__proto__:null,createElement:function(e,t,n){let r=document.createElement(e);if(t&&"object"==typeof t&&f(r,t),n)if(n instanceof Node)r.appendChild(n);else if(Array.isArray(n))for(let e of n)r.appendChild(e);return r},setElementAttrs:f,closestUntil:function(e,t,n){if("closest"in e&&!n)return e.closest(t);const r=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;do{if(r.call(e,t))return e;if(n&&e===n)return null;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null},prev:function(e,t){if(!e)return null;const n=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;do{if(n.call(e,t))return e;e=e.previousElementSibling||e.previousSibling}while(null!==e&&1===e.nodeType);return null},next:function(e,t){if(!e)return null;const n=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;do{if(n.call(e,t))return e;e=e.nextElementSibling||e.nextSibling}while(null!==e&&1===e.nodeType);return null},unwrapChildren:function(e){let t=e.parentNode;for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}});let g=null;const m=()=>{try{document.createElement("div").querySelector(":scope > div"),g=!0}catch(e){g=!1}};var y=Object.freeze({__proto__:null,getRootNode:function(e){if(!e)return null;if("getRootNode"in e)return e.getRootNode();for(;e.parentNode;)e=e.parentNode;return e},closest:function(e,t){if("closest"in e)return e.closest(t);const n=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;do{if(n.call(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null},remove:function(e){e&&("remove"in e?e.remove():e.parentNode&&e.parentNode.removeChild(e))},before:function(e,...t){if(0!==t.length)if("before"in e)e.before(...t);else if(1===t.length){let n=t[0];n=n instanceof Node?n:document.createTextNode(String(n)),e.parentNode.insertBefore(n,e)}else{let n=document.createDocumentFragment();for(const e of t){const t=e instanceof Node;n.appendChild(t?e:document.createTextNode(String(e)))}e.parentNode.insertBefore(n,e)}},after:function(e,...t){if(0!==t.length)if("after"in e)e.after(...t);else if(1===t.length){let n=t[0];n=n instanceof Node?n:document.createTextNode(String(n)),e.nextSibling?e.parentNode.insertBefore(n,e.nextSibling):e.parentNode.appendChild(n)}else{let n=document.createDocumentFragment();for(const e of t){const t=e instanceof Node;n.appendChild(t?e:document.createTextNode(String(e)))}e.nextSibling?e.parentNode.insertBefore(n,e.nextSibling):e.parentNode.appendChild(n)}},prepend:function(e,...t){if(0!==t.length)if("prepend"in e)e.prepend(...t);else if(1===t.length){let n=t[0];n=n instanceof Node?n:document.createTextNode(String(n)),e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n)}else{let n=document.createDocumentFragment();for(const e of t){const t=e instanceof Node;n.appendChild(t?e:document.createTextNode(String(e)))}e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n)}},append:function(e,...t){if(0!==t.length)if("append"in e)e.append(...t);else if(1===t.length){let n=t[0];n=n instanceof Node?n:document.createTextNode(String(n)),e.appendChild(n)}else{let n=document.createDocumentFragment();for(const e of t){const t=e instanceof Node;n.appendChild(t?e:document.createTextNode(String(e)))}e.appendChild(n)}},scopedSelector:function(e,t){if(null===g&&m(),!0===g)return e.querySelector(t.replace(/((?:^|,)\s*)/g,"$1:scope "));{let n=e.id;const r="ID_"+Date.now();e.id=r,t=t.replace(/((?:^|,)\s*)/g,"$1#"+r);try{return e.querySelector(t)}finally{this.id=n}}},scopedSelectorAll:function(e,t){if(null===g&&m(),!0===g)return e.querySelectorAll(t.replace(/((?:^|,)\s*)/g,"$1:scope "));{let n=e.id;const r="ID_"+Date.now();e.id=r,t=t.replace(/((?:^|,)\s*)/g,"$1#"+r);try{return e.querySelectorAll(t)}finally{this.id=n}}},toggleClass:function(e,t,n){let r=e.classList;return void 0===n?r.contains(t)?(r.remove(t),!1):(r.add(t),!0):n?(r.add(t),!0):(r.remove(t),!1)}}),v=Object.freeze({__proto__:null,default:class{constructor(){this._events=[]}add(e,t,n,r){let o=t.split("."),l=o[0],i=o[1];e.addEventListener(l,n,r||!1);let s=!0===r||"object"==typeof r&&!0===r.capture;return this._events.push({el:e,name:l,namespace:i,handler:n,useCapture:s}),this}remove(e,t,n,r){let o=t?t.split("."):"",l=o[0],i=o[1],s=!0===r||"object"==typeof r&&!0===r.capture,d=[],a=[];if(e||l||i||n||void 0!==r)for(let t of this._events)e&&t.el!==e||l&&t.name!==l||i&&t.namespace!==i||n&&t.handler!==n||void 0!==r&&t.useCapture!==s?d.push(t):a.push(t);else a=this._events;this._events=d;for(let e of a)e.el.removeEventListener(e.name,e.handler,e.useCapture);return this}}}),b=Object.freeze({__proto__:null,bindTouchTap:function(e,t){let n=null,r=null;const o=t=>{if(null!==n)return;let o=t.changedTouches[0];n=o.identifier,r=o?{x:o.pageX,y:o.pageY}:{x:t.pageX,y:t.pageY},e.addEventListener("touchend",l),e.addEventListener("touchcancel",i)},l=e=>{if(null===n)return;let o=null;if(e.changedTouches){if(null!=n)for(let t of e.changedTouches)if(t.identifier===n){o=t;break}o||(o=e.changedTouches[0])}let l=o?{x:o.pageX,y:o.pageY}:{x:e.pageX,y:e.pageY},i=r;if(n=null,r=null,null!==t.distance){let e=t.distance||1;if(Math.hypot(Math.abs(l.x-i.x),Math.abs(l.y-i.y))>=e)return!1}t.handler&&t.handler(e)},i=()=>{n=null,r=null,e.removeEventListener("touchend",l),e.removeEventListener("touchcancel",i)};return e.addEventListener("touchstart",o),{unbind:()=>{e.removeEventListener("touchstart",o),e.removeEventListener("touchend",l),e.removeEventListener("touchcancel",i)}}}});let S;const C=()=>{const e=document.createElement("div");e.dir="rtl",Object.assign(e.style,{direction:"rtl",fontSize:"14px",width:"1px",height:"1px",position:"absolute",top:"-1000px",overflow:"scroll"}),e.textContent="A",document.body.appendChild(e);let t="reverse";return e.scrollLeft>0?t="default":(e.scrollLeft=1,0===Math.floor(e.scrollLeft)&&(t="negative")),e.parentNode.removeChild(e),t};function E(e,t,n){if(void 0===n&&(n="rtl"===getComputedStyle(e).direction),!0===n&&void 0===S&&(S=C()),!n)return t;switch(S){case"negative":return t-e.scrollWidth+e.clientWidth;case"reverse":return e.scrollWidth-t-e.clientWidth;default:return t}}function w(e,t){if(void 0===t&&(t="rtl"===getComputedStyle(e).direction),!0===t&&void 0===S&&(S=C()),!t)return e.scrollLeft;switch(S){case"negative":return e.scrollLeft+e.scrollWidth-e.clientWidth;case"reverse":return e.scrollWidth-e.scrollLeft-e.clientWidth;default:return e.scrollLeft}}function x(e,t,n){return void 0===n&&(n="rtl"===getComputedStyle(e).direction),E(e,n?e.scrollWidth-e.clientWidth-t:t,n)}var N=Object.freeze({__proto__:null,calculateNativeScrollLeftForLeft:E,getScrollLeft:w,setScrollLeft:function(e,t,n){e.scrollLeft=E(e,t,n)},calculateNativeScrollLeftForHorz:x,getScrollHorz:function(e,t){return void 0===t&&(t="rtl"===getComputedStyle(e).direction),t?e.scrollWidth-e.clientWidth-w(e,t):w(e,t)},setScrollHorz:function(e,t,n){e.scrollLeft=x(e,t,n)}});export{u as Css,h as Dom,y as DomCompat,v as DomEventsSink,N as ScrollHelper,b as Touches};
|
|
5
|
+
const e=function(e,t){for(let[n,r]of Object.entries(t))e.style[n]=null==r?"":String(r)},t=function(e,t,n,r,o){return(...l)=>{let i,s,d,a,c=l[0];if(e?(i=l[1],s=!!l[2],d=!!l[3],a=!!l[4]):(s=!!l[1],d=!!l[2],a=!!l[3]),c===window)return c.document.documentElement[`client${n}`];if(9===c.nodeType){const e=c.documentElement,t=c.body;return Math.max(t[`scroll${n}`],e[`scroll${n}`],t[`offset${n}`],e[`offset${n}`],e[`client${n}`])}{let l,p,u=!1,f=!1;if(!e&&"getBoundingClientRect"in c&&(l=c.getBoundingClientRect()[t],u=!0,f=!0),(void 0===l||a||u!==s||f!==d)&&(p=e?getComputedStyle(c,i):getComputedStyle(c)),void 0===l){let e=p[t];"auto"===e?(l=c[`client${n}`],u=!0):l=parseFloat(e),"border-box"===p.boxSizing&&(u=!0,f=!0)}if(s!==u){let e=parseFloat(p[`padding-${r}`]||0)+parseFloat(p[`padding-${o}`]||0);s?l+=e:l-=e}if(d!==f){let e=parseFloat(p[`border-${r}-width`]||0)+parseFloat(p[`border-${o}-width`]||0);d?l+=e:l-=e}return l<0&&(l=0),a&&(l+=parseFloat(p[`margin-${r}`]||0)+parseFloat(p[`margin-${o}`]||0)),l}}},n=(e,t,n,r)=>(t,o,l=!1,i=!1,s=!1)=>{if(t===window)return;if(9===t.nodeType)return;const d=getComputedStyle(t);let a=!1;if("border-box"===d.boxSizing&&(a=!0),l=!!l,i=!!i,(s=!!s)&&(o-=(parseFloat(d[`margin-${n}`])||0)+(parseFloat(d[`margin-${r}`])||0)),l!==a){let e=parseFloat(d[`padding-${n}`]||0)+parseFloat(d[`padding-${r}`]||0);l?o-=e:o+=e}if(i!==a){let e=(parseFloat(d[`border-${n}-width`])||0)+(parseFloat(d[`border-${r}-width`])||0);i?o-=e:o+=e}o<0&&(o=0),t.style[e]=o+"px"},r=t(!1,"width","Width","left","right"),o=t(!1,"height","Height","top","bottom"),l=t(!0,"width","Width","left","right"),i=t(!0,"height","Height","top","bottom"),s=n("width",0,"left","right"),d=n("height",0,"top","bottom"),a=e=>{if(!e)return;let t=e.endsWith("ms");return parseFloat(e)*(t?1:1e3)},c=e=>/^-?(0?\.)?\d+m?s$/.test(e),p=e=>{let t=e.split(/\s+/),n=t[0],r=t[1],o=t[2],l=t[3];return c(o)?{delay:a(o),duration:a(r),name:n}:{delay:a(l),duration:a(r),name:n,timingFunction:o}};var u=Object.freeze({__proto__:null,anchoredPosition:function(e,t,n,o,l){let i,s,d,a;if(o||(o={width:r(e,!0,!0),height:r(e,!0,!0)}),"start"!==t&&"end"!==t||(null==l&&(l="rtl"===getComputedStyle(e).direction),t="start"===t?l?"right":"left":l?"left":"right"),"right"===t)i=o.width,d=0;else if("center"===t)i=o.width/2,d=i;else if("left"===t)i=0,d=o.width;else if(t&&"string"==typeof t&&"%"===t.charAt(t.length-1)){let n=(parseFloat(t)||0)/100;i=o.width*n,d=o.width*-n,null==l&&(l="rtl"===getComputedStyle(e).direction),l&&(i=o.width-i,d=o.width-i)}else i=parseFloat(t)||0,d=-i;if("bottom"===n)s=o.height,a=0;else if("center"===n)s=o.height/2,a=s;else if("top"===n)s=0,a=o.height;else if(n&&"string"==typeof n&&"%"===n.charAt(n.length-1)){let e=(parseFloat(n)||0)/100;s=o.height*e,a=o.height*-e}else s=parseFloat(n)||0,a=-s;return{left:i,top:s,right:d,bottom:a,xSpec:t,ySpec:n}},getCssProps:function(e,t){const n=getComputedStyle(e);let r={};for(let o of t){let t=n[o];("width"===o||"height"===o)&&"auto"===t&&e instanceof HTMLElement&&(t=e["offset"+o.substr(0,1).toUpperCase()+o.substr(1)],"border-box"!==n.boxSizing&&("width"===o?(t-=parseFloat(n.paddingLeft||0),t-=parseFloat(n.paddingRight||0),t-=parseFloat(n.borderLeftWidth||0),t-=parseFloat(n.borderRightWidth||0)):(t-=parseFloat(n.paddingTop||0),t-=parseFloat(n.paddingBottom||0),t-=parseFloat(n.borderTopWidth||0),t-=parseFloat(n.borderBottomWidth||0)),t<0&&(t=0)),t+="px"),r[o]=t}return r},getElementHeight:o,getElementOffset:e=>{if(!e.getClientRects().length)return{top:0,left:0};let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView;return{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}},getElementWidth:r,getPseudoElementHeight:i,getPseudoElementWidth:l,isTimeString:c,parseSingleTransition:p,parseTransition:e=>e?(e.match(/([^,()]|\([^)]*\))+/g)??[]).map((e=>e.trim())).filter((e=>e.length>0)).map(p):[],setCssProps:e,setElementHeight:d,setElementWidth:s,timeToMs:a});const f=function(t,n){for(let[r,o]of Object.entries(n))null!=o&&("innerHTML"===r?t.innerHTML=String(o):"css"===r&&"style"in t?e(t,o):r in t&&"style"!==r?t[r]=o:t.setAttribute(r,String(o)))};var h=Object.freeze({__proto__:null,closestUntil:function(e,t,n){if("closest"in e&&!n)return e.closest(t);const r=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;do{if(r.call(e,t))return e;if(n&&e===n)return null;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null},createElement:function(e,t,n){let r=document.createElement(e);if(t&&"object"==typeof t&&f(r,t),n)if(n instanceof Node)r.appendChild(n);else if(Array.isArray(n))for(let e of n)r.appendChild(e);return r},next:function(e,t){if(!e)return null;const n=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;do{if(n.call(e,t))return e;e=e.nextElementSibling||e.nextSibling}while(null!==e&&1===e.nodeType);return null},prev:function(e,t){if(!e)return null;const n=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;do{if(n.call(e,t))return e;e=e.previousElementSibling||e.previousSibling}while(null!==e&&1===e.nodeType);return null},setElementAttrs:f,unwrapChildren:function(e){let t=e.parentNode;for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}});let g=null;const m=()=>{try{document.createElement("div").querySelector(":scope > div"),g=!0}catch(e){g=!1}};var y=Object.freeze({__proto__:null,after:function(e,...t){if(0!==t.length)if("after"in e)e.after(...t);else if(1===t.length){let n=t[0];n=n instanceof Node?n:document.createTextNode(String(n)),e.nextSibling?e.parentNode.insertBefore(n,e.nextSibling):e.parentNode.appendChild(n)}else{let n=document.createDocumentFragment();for(const e of t){const t=e instanceof Node;n.appendChild(t?e:document.createTextNode(String(e)))}e.nextSibling?e.parentNode.insertBefore(n,e.nextSibling):e.parentNode.appendChild(n)}},append:function(e,...t){if(0!==t.length)if("append"in e)e.append(...t);else if(1===t.length){let n=t[0];n=n instanceof Node?n:document.createTextNode(String(n)),e.appendChild(n)}else{let n=document.createDocumentFragment();for(const e of t){const t=e instanceof Node;n.appendChild(t?e:document.createTextNode(String(e)))}e.appendChild(n)}},before:function(e,...t){if(0!==t.length)if("before"in e)e.before(...t);else if(1===t.length){let n=t[0];n=n instanceof Node?n:document.createTextNode(String(n)),e.parentNode.insertBefore(n,e)}else{let n=document.createDocumentFragment();for(const e of t){const t=e instanceof Node;n.appendChild(t?e:document.createTextNode(String(e)))}e.parentNode.insertBefore(n,e)}},closest:function(e,t){if("closest"in e)return e.closest(t);const n=Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;do{if(n.call(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null},getRootNode:function(e){if(!e)return null;if("getRootNode"in e)return e.getRootNode();for(;e.parentNode;)e=e.parentNode;return e},prepend:function(e,...t){if(0!==t.length)if("prepend"in e)e.prepend(...t);else if(1===t.length){let n=t[0];n=n instanceof Node?n:document.createTextNode(String(n)),e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n)}else{let n=document.createDocumentFragment();for(const e of t){const t=e instanceof Node;n.appendChild(t?e:document.createTextNode(String(e)))}e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n)}},remove:function(e){e&&("remove"in e?e.remove():e.parentNode&&e.parentNode.removeChild(e))},scopedSelector:function(e,t){if(null===g&&m(),!0===g)return e.querySelector(t.replace(/((?:^|,)\s*)/g,"$1:scope "));{let n=e.id;const r="ID_"+Date.now();e.id=r,t=t.replace(/((?:^|,)\s*)/g,"$1#"+r);try{return e.querySelector(t)}finally{this.id=n}}},scopedSelectorAll:function(e,t){if(null===g&&m(),!0===g)return e.querySelectorAll(t.replace(/((?:^|,)\s*)/g,"$1:scope "));{let n=e.id;const r="ID_"+Date.now();e.id=r,t=t.replace(/((?:^|,)\s*)/g,"$1#"+r);try{return e.querySelectorAll(t)}finally{this.id=n}}},toggleClass:function(e,t,n){let r=e.classList;return void 0===n?r.contains(t)?(r.remove(t),!1):(r.add(t),!0):n?(r.add(t),!0):(r.remove(t),!1)}}),v=Object.freeze({__proto__:null,default:class{constructor(){this._events=[]}add(e,t,n,r){let o=t.split("."),l=o[0],i=o[1];e.addEventListener(l,n,r||!1);let s=!0===r||"object"==typeof r&&!0===r.capture;return this._events.push({el:e,name:l,namespace:i,handler:n,useCapture:s}),this}remove(e,t,n,r){let o=t?t.split("."):"",l=o[0],i=o[1],s=!0===r||"object"==typeof r&&!0===r.capture,d=[],a=[];if(e||l||i||n||void 0!==r)for(let t of this._events)e&&t.el!==e||l&&t.name!==l||i&&t.namespace!==i||n&&t.handler!==n||void 0!==r&&t.useCapture!==s?d.push(t):a.push(t);else a=this._events;this._events=d;for(let e of a)e.el.removeEventListener(e.name,e.handler,e.useCapture);return this}}}),b=Object.freeze({__proto__:null,bindTouchTap:function(e,t){let n=null,r=null;const o=t=>{if(null!==n)return;let o=t.changedTouches[0];n=o.identifier,r=o?{x:o.pageX,y:o.pageY}:{x:t.pageX,y:t.pageY},e.addEventListener("touchend",l),e.addEventListener("touchcancel",i)},l=e=>{if(null===n)return;let o=null;if(e.changedTouches){if(null!=n)for(let t of e.changedTouches)if(t.identifier===n){o=t;break}o||(o=e.changedTouches[0])}let l=o?{x:o.pageX,y:o.pageY}:{x:e.pageX,y:e.pageY},i=r;if(n=null,r=null,null!==t.distance){let e=t.distance||1;if(Math.hypot(Math.abs(l.x-i.x),Math.abs(l.y-i.y))>=e)return!1}t.handler&&t.handler(e)},i=()=>{n=null,r=null,e.removeEventListener("touchend",l),e.removeEventListener("touchcancel",i)};return e.addEventListener("touchstart",o),{unbind:()=>{e.removeEventListener("touchstart",o),e.removeEventListener("touchend",l),e.removeEventListener("touchcancel",i)}}}});let S;const C=()=>{const e=document.createElement("div");e.dir="rtl",Object.assign(e.style,{direction:"rtl",fontSize:"14px",width:"1px",height:"1px",position:"absolute",top:"-1000px",overflow:"scroll"}),e.textContent="A",document.body.appendChild(e);let t="reverse";return e.scrollLeft>0?t="default":(e.scrollLeft=1,0===Math.floor(e.scrollLeft)&&(t="negative")),e.parentNode.removeChild(e),t};function E(e,t,n){if(void 0===n&&(n="rtl"===getComputedStyle(e).direction),!0===n&&void 0===S&&(S=C()),!n)return t;switch(S){case"negative":return t-e.scrollWidth+e.clientWidth;case"reverse":return e.scrollWidth-t-e.clientWidth;default:return t}}function w(e,t){if(void 0===t&&(t="rtl"===getComputedStyle(e).direction),!0===t&&void 0===S&&(S=C()),!t)return e.scrollLeft;switch(S){case"negative":return e.scrollLeft+e.scrollWidth-e.clientWidth;case"reverse":return e.scrollWidth-e.scrollLeft-e.clientWidth;default:return e.scrollLeft}}function x(e,t,n){return void 0===n&&(n="rtl"===getComputedStyle(e).direction),E(e,n?e.scrollWidth-e.clientWidth-t:t,n)}var N=Object.freeze({__proto__:null,calculateNativeScrollLeftForHorz:x,calculateNativeScrollLeftForLeft:E,getScrollHorz:function(e,t){return void 0===t&&(t="rtl"===getComputedStyle(e).direction),t?e.scrollWidth-e.clientWidth-w(e,t):w(e,t)},getScrollLeft:w,setScrollHorz:function(e,t,n){e.scrollLeft=x(e,t,n)},setScrollLeft:function(e,t,n){e.scrollLeft=E(e,t,n)}});export{u as Css,h as Dom,y as DomCompat,v as DomEventsSink,N as ScrollHelper,b as Touches};
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
6
7
|
|
|
7
8
|
//# sourceMappingURL=lib.es6.min.js.map
|