shorter-js
Advanced tools
Comparing version 0.3.0-alpha3 to 0.3.0-alpha4
/*! | ||
* shorter-js v0.3.0alpha3 (https://github.com/thednp/shorter-js) | ||
* shorter-js v0.3.0alpha4 (https://github.com/thednp/shorter-js) | ||
* Copyright 2019-2022 © dnp_theme | ||
@@ -991,3 +991,3 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
* | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @param {any[] | HTMLCollection | NodeList | Map<any, any>} arr array-like iterable object | ||
* @returns {Array<any>} | ||
@@ -1043,3 +1043,3 @@ */ | ||
* @param {string} component the component's name or a unique key | ||
* @returns {Map<HTMLElement, SHORTER.Component> | null} all the component instances | ||
* @returns {Map<HTMLElement, SHORTER.Component>?} all the component instances | ||
*/ | ||
@@ -1057,3 +1057,3 @@ getAllFor: (component) => { | ||
* @param {string} component the component's name or a unique key | ||
* @returns {SHORTER.Component | null} the instance | ||
* @returns {SHORTER.Component?} the instance | ||
*/ | ||
@@ -1630,3 +1630,5 @@ get: (target, component) => { | ||
function getBoundingClientRect(element, includeScale) { | ||
const clientRect = element.getBoundingClientRect(); | ||
const { | ||
width, height, top, right, bottom, left, | ||
} = element.getBoundingClientRect(); | ||
let scaleX = 1; | ||
@@ -1637,16 +1639,16 @@ let scaleY = 1; | ||
scaleX = element.offsetWidth > 0 | ||
? Math.round(clientRect.width) / element.offsetWidth || 1 : 1; | ||
? Math.round(width) / element.offsetWidth || 1 : 1; | ||
scaleY = element.offsetHeight > 0 | ||
? Math.round(clientRect.height) / element.offsetHeight || 1 : 1; | ||
? Math.round(height) / element.offsetHeight || 1 : 1; | ||
} | ||
return { | ||
width: clientRect.width / scaleX, | ||
height: clientRect.height / scaleY, | ||
top: clientRect.top / scaleY, | ||
right: clientRect.right / scaleX, | ||
bottom: clientRect.bottom / scaleY, | ||
left: clientRect.left / scaleX, | ||
x: clientRect.left / scaleX, | ||
y: clientRect.top / scaleY, | ||
width: width / scaleX, | ||
height: height / scaleY, | ||
top: top / scaleY, | ||
right: right / scaleX, | ||
bottom: bottom / scaleY, | ||
left: left / scaleX, | ||
x: left / scaleX, | ||
y: top / scaleY, | ||
}; | ||
@@ -1656,13 +1658,64 @@ } | ||
/** | ||
* Returns the `document.documentElement` or the `<html>` element. | ||
* Check if a target node is `window`. | ||
* | ||
* @param {any} node the target node | ||
* @returns {boolean} the query result | ||
*/ | ||
function isWindow(node) { | ||
return node instanceof Window; | ||
} | ||
/** | ||
* Checks if an object is a `Node`. | ||
* | ||
* @param {any} node the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isNode = (node) => node instanceof Node; | ||
/** | ||
* Returns the `document` or the `#document` element. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* @param {Node | Window} node | ||
* @param {(Node | HTMLElement | Element | Window)=} node | ||
* @returns {Document} | ||
*/ | ||
function getDocument(node) { | ||
// @ts-ignore -- `isNode` checks that | ||
if (isNode(node)) return node.ownerDocument; | ||
// @ts-ignore -- `isWindow` checks that too | ||
if (isWindow(node)) return node.document; | ||
return window.document; | ||
} | ||
/** | ||
* Returns the `document.body` or the `<body>` element. | ||
* | ||
* @param {(Node | HTMLElement | Element)=} node | ||
* @returns {HTMLElement} | ||
*/ | ||
function getDocumentBody(node) { | ||
return getDocument(node).body; | ||
} | ||
/** | ||
* Returns the `document.documentElement` or the `<html>` element. | ||
* | ||
* @param {(Node | HTMLElement | Element)=} node | ||
* @returns {HTMLElement} | ||
*/ | ||
function getDocumentElement(node) { | ||
const doc = (node instanceof Node ? node.ownerDocument : node.document) || window.document; | ||
return doc.documentElement; | ||
return getDocument(node).documentElement; | ||
} | ||
/** | ||
* Returns the `document.head` or the `<head>` element. | ||
* | ||
* @param {(Node | HTMLElement | Element)=} node | ||
* @returns {HTMLElement} | ||
*/ | ||
function getDocumentHead(node) { | ||
return getDocument(node).head; | ||
} | ||
/** | ||
* Returns an `{x,y}` object with the target | ||
@@ -1685,8 +1738,23 @@ * `Element` / `Node` scroll position. | ||
/** | ||
* Check if a target element is a `<table>`, `<td>` or `<th>`. | ||
* @param {any} element the target element | ||
* @returns {boolean} the query result | ||
* Returns the `Window` object of a target node. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {(Node | Element | HTMLElement | Window)=} node target node | ||
* @returns {globalThis} the `Window` object | ||
*/ | ||
const isTableElement = (element) => ['TABLE', 'TD', 'TH'].includes(element.tagName); | ||
function getWindow(node) { | ||
if (node == null) { | ||
return window; | ||
} | ||
if (!isWindow(node)) { | ||
// @ts-ignore | ||
const { ownerDocument } = node; | ||
return ownerDocument ? ownerDocument.defaultView || window : window; | ||
} | ||
// @ts-ignore -- we know it's window, we checked above | ||
return node; | ||
} | ||
/** | ||
@@ -1699,4 +1767,3 @@ * Check if target is a `ShadowRoot`. | ||
const isShadowRoot = (element) => { | ||
// eslint-disable-next-line no-restricted-globals | ||
const OwnElement = (self || window).ShadowRoot; | ||
const OwnElement = getWindow(element).ShadowRoot; | ||
return element instanceof OwnElement || element instanceof ShadowRoot; | ||
@@ -1728,115 +1795,2 @@ }; | ||
/** | ||
* Check if a target node is `window`. | ||
* | ||
* @param {any} node the target node | ||
* @returns {boolean} the query result | ||
*/ | ||
function isWindow(node) { | ||
// eslint-disable-next-line no-restricted-globals | ||
return [self, window].includes(node); | ||
} | ||
/** | ||
* Returns the `Window` object of a target node. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {(Node | Element | Window)=} node target node | ||
* @returns {Window} the `Window` object | ||
*/ | ||
function getWindow(node) { | ||
if (node == null) { | ||
return window; | ||
} | ||
if (!isWindow(node)) { | ||
// @ts-ignore | ||
const { ownerDocument } = node; | ||
return ownerDocument ? ownerDocument.defaultView || window : window; | ||
} | ||
// @ts-ignore | ||
return node; | ||
} | ||
/** | ||
* @param {Node} element | ||
* @returns {boolean} | ||
*/ | ||
function isContainingBlock(element) { | ||
// TODO: Try and use feature detection here instead | ||
const { | ||
transform, perspective, contain, willChange, filter, | ||
// @ts-ignore | ||
} = getComputedStyle(element); | ||
// This is non-exhaustive but covers the most common CSS properties that | ||
// create a containing block. | ||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block | ||
return transform !== 'none' | ||
|| perspective !== 'none' | ||
|| contain === 'paint' | ||
|| ['transform', 'perspective'].includes(willChange) | ||
|| (isFirefox && willChange === 'filter') | ||
|| (isFirefox && (filter ? filter !== 'none' : false)); | ||
} | ||
/** | ||
* @param {Node} element | ||
* @returns {(Node | ParentNode)?} | ||
*/ | ||
function getContainingBlock(element) { | ||
let currentNode = getParentNode(element); | ||
while (isHTMLElement(currentNode) && !['HTML', 'BODY'].includes(currentNode.nodeName)) { | ||
if (isContainingBlock(currentNode)) { | ||
return currentNode; | ||
} | ||
// @ts-ignore | ||
currentNode = currentNode.parentNode; | ||
} | ||
return null; | ||
} | ||
/** | ||
* @param {HTMLElement} element | ||
* @returns {HTMLElement?} | ||
*/ | ||
function getTrueOffsetParent(element) { | ||
if (!isHTMLElement(element) || getElementStyle(element, 'position') === 'fixed') { | ||
return null; | ||
} | ||
// @ts-ignore | ||
return element.offsetParent; | ||
} | ||
/** | ||
* Returns the best possible container for offsets computation. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* | ||
* @param {HTMLElement} element target element | ||
* @returns {HTMLElement | Window | Node} the best `Node` / `Element` match | ||
*/ | ||
function getOffsetParent(element) { | ||
// eslint-disable-next-line no-restricted-globals | ||
const win = getWindow(element); | ||
let offsetParent = getTrueOffsetParent(element); | ||
while (offsetParent && isTableElement(offsetParent) | ||
&& getElementStyle(offsetParent, 'position') === 'static') { | ||
offsetParent = getTrueOffsetParent(offsetParent); | ||
} | ||
if (offsetParent | ||
&& (['HTML', 'BODY'].includes(offsetParent.tagName) | ||
&& getElementStyle(offsetParent, 'position') === 'static' | ||
&& !isContainingBlock(offsetParent))) { | ||
return win; | ||
} | ||
return offsetParent || getContainingBlock(element) || win; | ||
} | ||
/** | ||
* Checks if a target `HTMLElement` is affected by scale. | ||
@@ -1859,8 +1813,8 @@ * @see https://github.com/floating-ui/floating-ui | ||
* @param {HTMLElement} element target | ||
* @param {HTMLElement} offsetParent the container / offset parent | ||
* @param {HTMLElement | globalThis} offsetParent the container / offset parent | ||
* @param {{x: number, y: number}} scroll | ||
* @returns {Record<string, number>} | ||
* @returns {Partial<SHORTER.BoundingClientRect>} | ||
*/ | ||
function getRectRelativeToOffsetParent(element, offsetParent, scroll) { | ||
const isParentAnElement = isHTMLElement(offsetParent); | ||
const isParentAnElement = isHTMLElement(offsetParent); // @ts-ignore -- `isParentAnElement` checks | ||
const rect = getBoundingClientRect(element, isParentAnElement && isScaledElement(offsetParent)); | ||
@@ -1870,4 +1824,7 @@ const offsets = { x: 0, y: 0 }; | ||
if (isParentAnElement) { | ||
// @ts-ignore -- `isParentAnElement` checks | ||
const offsetRect = getBoundingClientRect(offsetParent, true); | ||
// @ts-ignore -- `isParentAnElement` checks | ||
offsets.x = offsetRect.x + offsetParent.clientLeft; | ||
// @ts-ignore -- `isParentAnElement` checks | ||
offsets.y = offsetRect.y + offsetParent.clientTop; | ||
@@ -1908,5 +1865,6 @@ } | ||
const isElementInScrollRange = (element) => { | ||
const bcr = element.getBoundingClientRect(); | ||
const viewportHeight = window.innerHeight || document.documentElement.clientHeight; | ||
return bcr.top <= viewportHeight && bcr.bottom >= 0; // bottom && top | ||
const { top, bottom } = getBoundingClientRect(element); | ||
const html = getDocumentElement(element); | ||
// checks bottom && top | ||
return top <= html.clientHeight && bottom >= 0; | ||
}; | ||
@@ -1968,10 +1926,2 @@ | ||
/** | ||
* Checks if an object is a `Node`. | ||
* | ||
* @param {any} node the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isNode = (node) => node instanceof Node; | ||
/** | ||
* Checks if an object is a `NodeList`. | ||
@@ -1986,8 +1936,6 @@ * | ||
* Checks if a page is Right To Left. | ||
* @param {HTMLElement} node the target | ||
* @returns {boolean} the query result | ||
*/ | ||
const isRTL = () => [ | ||
document.body, | ||
document.documentElement, | ||
].some((el) => el.dir === 'rtl'); | ||
const isRTL = (node) => getDocumentElement(node).dir === 'rtl'; | ||
@@ -2010,2 +1958,9 @@ /** | ||
/** | ||
* Check if a target element is a `<table>`, `<td>` or `<th>`. | ||
* @param {any} element the target element | ||
* @returns {boolean} the query result | ||
*/ | ||
const isTableElement = (element) => ['TABLE', 'TD', 'TH'].includes(element.tagName); | ||
/** | ||
* Shortcut for `HTMLElement.closest` method. | ||
@@ -2076,3 +2031,3 @@ * | ||
var version = "0.3.0alpha3"; | ||
var version = "0.3.0alpha4"; | ||
@@ -2232,3 +2187,2 @@ // @ts-ignore | ||
getNodeScroll, | ||
getOffsetParent, | ||
getParentNode, | ||
@@ -2271,3 +2225,6 @@ getRectRelativeToOffsetParent, | ||
getBoundingClientRect, | ||
getDocument, | ||
getDocumentBody, | ||
getDocumentElement, | ||
getDocumentHead, | ||
getElementStyle, | ||
@@ -2274,0 +2231,0 @@ setElementStyle, |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.3.0alpha3 | dnp_theme © 2022 | MIT-License | ||
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",o="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",{userAgentData:u}=navigator,l=u,{userAgent:m}=navigator,d=m,g=/iPhone|iPad|iPod|Android/i;let f=!1;f=l?l.brands.some(e=>g.test(e.brand)):g.test(d);const E=f,p=/(iPhone|iPod|iPad)/,y=l?l.brands.some(e=>p.test(e.brand)):p.test(d),b=!!d&&d.includes("Firefox"),h="webkitPerspective"in document.head.style||"perspective"in document.head.style;function v(e,t,n,o){const i=o||!1;e.addEventListener(t,n,i)}function w(e,t,n,o){const i=o||!1;e.removeEventListener(t,n,i)}function A(e,t,n,o){v(e,t,(function i(a){a.target===e&&(n.apply(e,[a]),w(e,t,i,o))}),o)}const k=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});A(document,"DOMContentLoaded",()=>{},t)}catch(e){throw Error("Passive events are not supported")}return e})(),L="webkitTransform"in document.head.style||"transform"in document.head.style,N="ontouchstart"in window||"msMaxTouchPoints"in navigator,D="webkitAnimation"in document.head.style||"animation"in document.head.style,T="webkitTransition"in document.head.style||"transition"in document.head.style;function S(e,t){const n=[HTMLElement,Element,Node],o=t&&n.some(e=>t instanceof e)?t:document;return n.some(t=>e instanceof t)?e:o.querySelector(e)}const M=new Map,C={set:(e,t,n)=>{const o=S(e);if(!o)return;M.has(t)||M.set(t,new Map);M.get(t).set(o,n)},getAllFor:e=>{const t=M.get(e);return t||null},get:(e,t)=>{const n=S(e),o=C.getAllFor(t),i=n&&o&&o.get(n);return i||null},remove:(e,t)=>{const n=S(e),o=M.get(t);o&&n&&(o.delete(n),0===o.size&&M.delete(t))}};function O(e,t){const n=getComputedStyle(e);return t in n?n[t]:""}function z(e){const t=O(e,"animationName"),n=O(e,"animationDelay"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function H(e){const t=O(e,"animationName"),n=O(e,"animationDuration"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function P(e){const t=O(e,o),i=O(e,n),a=i.includes("ms")?1:1e3,r=D&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(r)?0:r}function I(e){const n=O(e,o),i=O(e,t),a=i.includes("ms")?1:1e3,r=D&&n&&"none"!==n?parseFloat(i)*a:0;return Number.isNaN(r)?0:r}function x(e){const t=O(e,"transitionProperty"),n=O(e,"transitionDelay"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function B(e){const t=O(e,"transitionProperty"),n=O(e,"transitionDuration"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function F(e){const t=O(e,c),n=O(e,r),o=n.includes("ms")?1:1e3,i=T&&t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function R(e){const t=O(e,c),n=O(e,a),o=n.includes("ms")?1:1e3,i=T&&t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function W(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const Q=e=>Object.keys(e);const V=(e,t)=>Object.assign(e,t),j=!!k&&{passive:!0},q=new Map;const U=e=>e instanceof HTMLElement;function G(e,t){const n=e.getBoundingClientRect();let o=1,i=1;return t&&U(e)&&(o=e.offsetWidth>0&&Math.round(n.width)/e.offsetWidth||1,i=e.offsetHeight>0&&Math.round(n.height)/e.offsetHeight||1),{width:n.width/o,height:n.height/i,top:n.top/i,right:n.right/o,bottom:n.bottom/i,left:n.left/o,x:n.left/o,y:n.top/i}}function Y(e){return((e instanceof Node?e.ownerDocument:e.document)||window.document).documentElement}const K=e=>["TABLE","TD","TH"].includes(e.tagName),X=e=>e instanceof(self||window).ShadowRoot||e instanceof ShadowRoot;function $(e){return"HTML"===e.nodeName?e:e.assignedSlot||e.parentNode||(X(e)?e.host:null)||Y(e)}function Z(e){return[self,window].includes(e)}function J(e){if(null==e)return window;if(!Z(e)){const{ownerDocument:t}=e;return t&&t.defaultView||window}return e}function _(e){const{transform:t,perspective:n,contain:o,willChange:i,filter:a}=getComputedStyle(e);return"none"!==t||"none"!==n||"paint"===o||["transform","perspective"].includes(i)||b&&"filter"===i||b&&!!a&&"none"!==a}function ee(e){return U(e)&&"fixed"!==O(e,"position")?e.offsetParent:null}function te(e){const t=G(e);return Math.round(t.width)!==e.offsetWidth||Math.round(t.height)!==e.offsetHeight}const ne={ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:o,animationEndEvent:"animationend",animationEndEventLegacy:i,transitionDuration:"transitionDuration",transitionDurationLegacy:a,transitionDelay:"transitionDelay",transitionDelayLegacy:r,transitionEndEvent:"transitionend",transitionEndEventLegacy:s,transitionProperty:"transitionProperty",transitionPropertyLegacy:c,isMobile:E,isApple:y,isFirefox:b,support3DTransform:h,supportPassive:k,supportTransform:L,supportTouch:N,supportAnimation:D,supportTransition:T,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:l,userAgent:d,addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:v,off:w,one:A,Data:C,Timer:{set:(e,t,n,o)=>{const i=S(e);if(i)if(o&&o.length){q.has(i)||q.set(i,new Map);q.get(i).set(o,setTimeout(t,n))}else q.set(i,setTimeout(t,n))},get:(e,t)=>{const n=S(e);if(!n)return null;if(t&&t.length){q.has(n)||q.set(n,new Map);const e=q.get(n);if(e.has(t))return e.get(t)}else if(q.has(n))return q.get(n);return null},clear:(e,t)=>{const n=S(e),o=n&&q.get(n);o&&(t&&t.length?o.has(t)&&(clearTimeout(o.get(t)),o.delete(t)):(clearTimeout(o),q.delete(n)))}},getInstance:(e,t)=>C.get(e,t),emulateAnimationEnd:function(e,t){let n=0;const o=new Event("animationend"),i=H(e),a=z(e);if(i){const r=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener("animationend",r),n=1)};e.addEventListener("animationend",r),setTimeout(()=>{n||e.dispatchEvent(o)},i+a+17)}else t.apply(e,[o])},emulateAnimationEndLegacy:function(e,t){let n=0;const o=new Event(i),a=I(e),r=P(e);if(D&&a){const s=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener(i,s),n=1)};e.addEventListener(i,s),setTimeout(()=>{n||e.dispatchEvent(o)},a+r+17)}else t.apply(e,[o])},emulateTransitionEnd:function(e,t){let n=0;const o=new Event("transitionend"),i=B(e),a=x(e);if(i){const r=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener("transitionend",r),n=1)};e.addEventListener("transitionend",r),setTimeout(()=>{n||e.dispatchEvent(o)},i+a+17)}else t.apply(e,[o])},emulateTransitionEndLegacy:function(e,t){let n=0;const o=new Event(s),i=R(e),a=F(e);if(T&&i){const r=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener(s,r),n=1)};e.addEventListener(s,r),setTimeout(()=>{n||e.dispatchEvent(o)},i+a+17)}else t.apply(e,[o])},isElementInScrollRange:e=>{const t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:e=>{const t=G(e,!0);return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:j,getElementAnimationDuration:H,getElementAnimationDurationLegacy:I,getElementAnimationDelay:z,getElementAnimationDelayLegacy:P,getElementTransitionDuration:B,getElementTransitionDurationLegacy:R,getElementTransitionDelay:x,getElementTransitionDelayLegacy:F,getNodeScroll:function(e){const t="scrollX"in e;return{x:t?e.scrollX:e.scrollLeft,y:t?e.scrollY:e.scrollTop}},getOffsetParent:function(e){const t=J(e);let n=ee(e);for(;n&&K(n)&&"static"===O(n,"position");)n=ee(n);return n&&["HTML","BODY"].includes(n.tagName)&&"static"===O(n,"position")&&!_(n)?t:n||function(e){let t=$(e);for(;U(t)&&!["HTML","BODY"].includes(t.nodeName);){if(_(t))return t;t=t.parentNode}return null}(e)||t},getParentNode:$,getRectRelativeToOffsetParent:function(e,t,n){const o=U(t),i=G(e,o&&te(t)),a={x:0,y:0};if(o){const e=G(t,!0);a.x=e.x+t.clientLeft,a.y=e.y+t.clientTop}return{x:i.left+n.x-a.x,y:i.top+n.y-a.y,width:i.width,height:i.height}},getWindow:J,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isElement:e=>e instanceof Element,isNode:e=>e instanceof Node,isHTMLElement:U,isHTMLImageElement:e=>e instanceof HTMLImageElement,isSVGElement:e=>e instanceof SVGElement,isNodeList:e=>e instanceof NodeList,isHTMLCollection:e=>e instanceof HTMLCollection,isScaledElement:te,isTableElement:K,isShadowRoot:X,isElementsArray:e=>Array.isArray(e)&&e.every(e=>U(e)),isWindow:Z,isMedia:e=>e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(t=>e instanceof t),isRTL:()=>[document.body,document.documentElement].some(e=>"rtl"===e.dir),closest:function(e,t){return e&&t?e.closest(t):null},querySelector:S,getCustomElements:function(e){return[...(e&&U(e)?e:document).querySelectorAll("*")].filter(e=>customElements.get(e.nodeName.toLowerCase()))},querySelectorAll:function(e,t){return(t&&[HTMLElement,Element,Node].some(e=>t instanceof e)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&U(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&U(t)?t:document).getElementsByTagName(e)},normalizeValue:W,normalizeOptions:function(e,t,n,o){const i={...e.dataset},a={},r={};return Q(i).forEach(e=>{const t=o&&e.includes(o)?e.replace(o,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;r[t]=W(i[e])}),Q(n).forEach(e=>{n[e]=W(n[e])}),Q(t).forEach(e=>{a[e]=e in n?n[e]:e in r?r[e]:t[e]}),a},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(`${t} ${e}`)}},reflow:e=>e.offsetHeight,focus:e=>e.focus(),ArrayFrom:e=>Array.from(e),Float32ArrayFrom:e=>Float32Array.from(Array.from(e)),Float64ArrayFrom:e=>Float64Array.from(Array.from(e)),ObjectAssign:V,ObjectKeys:Q,ObjectValues:e=>Object.values(e),getBoundingClientRect:G,getDocumentElement:Y,getElementStyle:O,setElementStyle:(e,t)=>{V(e.style,t)},hasAttribute:(e,t)=>e.hasAttribute(t),hasAttributeNS:(e,t,n)=>e.hasAttributeNS(n||null,t),getAttribute:(e,t)=>e.getAttribute(t),getAttributeNS:(e,t,n)=>e.getAttributeNS(n||null,t),setAttribute:(e,t,n)=>e.setAttribute(t,n),setAttributeNS:(e,t,n,o)=>e.setAttributeNS(o||null,t,n),removeAttribute:(e,t)=>e.removeAttribute(t),removeAttributeNS:(e,t,n)=>e.removeAttributeNS(n||null,t),Version:"0.3.0alpha3"};export{ne as default}; | ||
// shorter-js v0.3.0alpha4 | dnp_theme © 2022 | MIT-License | ||
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",o="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",{userAgentData:u}=navigator,l=u,{userAgent:m}=navigator,d=m,g=/iPhone|iPad|iPod|Android/i;let E=!1;E=l?l.brands.some(e=>g.test(e.brand)):g.test(d);const f=E,y=/(iPhone|iPod|iPad)/,b=l?l.brands.some(e=>y.test(e.brand)):y.test(d),p=!!d&&d.includes("Firefox"),v="webkitPerspective"in document.head.style||"perspective"in document.head.style;function h(e,t,n,o){const i=o||!1;e.addEventListener(t,n,i)}function w(e,t,n,o){const i=o||!1;e.removeEventListener(t,n,i)}function A(e,t,n,o){h(e,t,(function i(a){a.target===e&&(n.apply(e,[a]),w(e,t,i,o))}),o)}const k=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});A(document,"DOMContentLoaded",()=>{},t)}catch(e){throw Error("Passive events are not supported")}return e})(),L="webkitTransform"in document.head.style||"transform"in document.head.style,D="ontouchstart"in window||"msMaxTouchPoints"in navigator,N="webkitAnimation"in document.head.style||"animation"in document.head.style,T="webkitTransition"in document.head.style||"transition"in document.head.style;function S(e,t){const n=[HTMLElement,Element,Node],o=t&&n.some(e=>t instanceof e)?t:document;return n.some(t=>e instanceof t)?e:o.querySelector(e)}const M=new Map,C={set:(e,t,n)=>{const o=S(e);if(!o)return;M.has(t)||M.set(t,new Map);M.get(t).set(o,n)},getAllFor:e=>{const t=M.get(e);return t||null},get:(e,t)=>{const n=S(e),o=C.getAllFor(t),i=n&&o&&o.get(n);return i||null},remove:(e,t)=>{const n=S(e),o=M.get(t);o&&n&&(o.delete(n),0===o.size&&M.delete(t))}};function O(e,t){const n=getComputedStyle(e);return t in n?n[t]:""}function z(e){const t=O(e,"animationName"),n=O(e,"animationDelay"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function H(e){const t=O(e,"animationName"),n=O(e,"animationDuration"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function I(e){const t=O(e,o),i=O(e,n),a=i.includes("ms")?1:1e3,r=N&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(r)?0:r}function P(e){const n=O(e,o),i=O(e,t),a=i.includes("ms")?1:1e3,r=N&&n&&"none"!==n?parseFloat(i)*a:0;return Number.isNaN(r)?0:r}function x(e){const t=O(e,"transitionProperty"),n=O(e,"transitionDelay"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function F(e){const t=O(e,"transitionProperty"),n=O(e,"transitionDuration"),o=n.includes("ms")?1:1e3,i=t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function B(e){const t=O(e,c),n=O(e,r),o=n.includes("ms")?1:1e3,i=T&&t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function R(e){const t=O(e,c),n=O(e,a),o=n.includes("ms")?1:1e3,i=T&&t&&"none"!==t?parseFloat(n)*o:0;return Number.isNaN(i)?0:i}function W(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const Q=e=>Object.keys(e);const V=(e,t)=>Object.assign(e,t),j=!!k&&{passive:!0},q=new Map;const U=e=>e instanceof HTMLElement;function G(e,t){const{width:n,height:o,top:i,right:a,bottom:r,left:s}=e.getBoundingClientRect();let c=1,u=1;return t&&U(e)&&(c=e.offsetWidth>0&&Math.round(n)/e.offsetWidth||1,u=e.offsetHeight>0&&Math.round(o)/e.offsetHeight||1),{width:n/c,height:o/u,top:i/u,right:a/c,bottom:r/u,left:s/c,x:s/c,y:i/u}}function K(e){return e instanceof Window}const X=e=>e instanceof Node;function $(e){return X(e)?e.ownerDocument:K(e)?e.document:window.document}function Y(e){return $(e).documentElement}function Z(e){if(null==e)return window;if(!K(e)){const{ownerDocument:t}=e;return t&&t.defaultView||window}return e}const J=e=>e instanceof Z(e).ShadowRoot||e instanceof ShadowRoot;function _(e){const t=G(e);return Math.round(t.width)!==e.offsetWidth||Math.round(t.height)!==e.offsetHeight}const ee={ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:o,animationEndEvent:"animationend",animationEndEventLegacy:i,transitionDuration:"transitionDuration",transitionDurationLegacy:a,transitionDelay:"transitionDelay",transitionDelayLegacy:r,transitionEndEvent:"transitionend",transitionEndEventLegacy:s,transitionProperty:"transitionProperty",transitionPropertyLegacy:c,isMobile:f,isApple:b,isFirefox:p,support3DTransform:v,supportPassive:k,supportTransform:L,supportTouch:D,supportAnimation:N,supportTransition:T,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:l,userAgent:d,addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:h,off:w,one:A,Data:C,Timer:{set:(e,t,n,o)=>{const i=S(e);if(i)if(o&&o.length){q.has(i)||q.set(i,new Map);q.get(i).set(o,setTimeout(t,n))}else q.set(i,setTimeout(t,n))},get:(e,t)=>{const n=S(e);if(!n)return null;if(t&&t.length){q.has(n)||q.set(n,new Map);const e=q.get(n);if(e.has(t))return e.get(t)}else if(q.has(n))return q.get(n);return null},clear:(e,t)=>{const n=S(e),o=n&&q.get(n);o&&(t&&t.length?o.has(t)&&(clearTimeout(o.get(t)),o.delete(t)):(clearTimeout(o),q.delete(n)))}},getInstance:(e,t)=>C.get(e,t),emulateAnimationEnd:function(e,t){let n=0;const o=new Event("animationend"),i=H(e),a=z(e);if(i){const r=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener("animationend",r),n=1)};e.addEventListener("animationend",r),setTimeout(()=>{n||e.dispatchEvent(o)},i+a+17)}else t.apply(e,[o])},emulateAnimationEndLegacy:function(e,t){let n=0;const o=new Event(i),a=P(e),r=I(e);if(N&&a){const s=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener(i,s),n=1)};e.addEventListener(i,s),setTimeout(()=>{n||e.dispatchEvent(o)},a+r+17)}else t.apply(e,[o])},emulateTransitionEnd:function(e,t){let n=0;const o=new Event("transitionend"),i=F(e),a=x(e);if(i){const r=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener("transitionend",r),n=1)};e.addEventListener("transitionend",r),setTimeout(()=>{n||e.dispatchEvent(o)},i+a+17)}else t.apply(e,[o])},emulateTransitionEndLegacy:function(e,t){let n=0;const o=new Event(s),i=R(e),a=B(e);if(T&&i){const r=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener(s,r),n=1)};e.addEventListener(s,r),setTimeout(()=>{n||e.dispatchEvent(o)},i+a+17)}else t.apply(e,[o])},isElementInScrollRange:e=>{const{top:t,bottom:n}=G(e);return t<=Y(e).clientHeight&&n>=0},isElementInViewport:e=>{const t=G(e,!0);return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:j,getElementAnimationDuration:H,getElementAnimationDurationLegacy:P,getElementAnimationDelay:z,getElementAnimationDelayLegacy:I,getElementTransitionDuration:F,getElementTransitionDurationLegacy:R,getElementTransitionDelay:x,getElementTransitionDelayLegacy:B,getNodeScroll:function(e){const t="scrollX"in e;return{x:t?e.scrollX:e.scrollLeft,y:t?e.scrollY:e.scrollTop}},getParentNode:function(e){return"HTML"===e.nodeName?e:e.assignedSlot||e.parentNode||(J(e)?e.host:null)||Y(e)},getRectRelativeToOffsetParent:function(e,t,n){const o=U(t),i=G(e,o&&_(t)),a={x:0,y:0};if(o){const e=G(t,!0);a.x=e.x+t.clientLeft,a.y=e.y+t.clientTop}return{x:i.left+n.x-a.x,y:i.top+n.y-a.y,width:i.width,height:i.height}},getWindow:Z,isArray:e=>Array.isArray(e),isString:e=>"string"==typeof e,isElement:e=>e instanceof Element,isNode:X,isHTMLElement:U,isHTMLImageElement:e=>e instanceof HTMLImageElement,isSVGElement:e=>e instanceof SVGElement,isNodeList:e=>e instanceof NodeList,isHTMLCollection:e=>e instanceof HTMLCollection,isScaledElement:_,isTableElement:e=>["TABLE","TD","TH"].includes(e.tagName),isShadowRoot:J,isElementsArray:e=>Array.isArray(e)&&e.every(e=>U(e)),isWindow:K,isMedia:e=>e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(t=>e instanceof t),isRTL:e=>"rtl"===Y(e).dir,closest:function(e,t){return e&&t?e.closest(t):null},querySelector:S,getCustomElements:function(e){return[...(e&&U(e)?e:document).querySelectorAll("*")].filter(e=>customElements.get(e.nodeName.toLowerCase()))},querySelectorAll:function(e,t){return(t&&[HTMLElement,Element,Node].some(e=>t instanceof e)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&U(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&U(t)?t:document).getElementsByTagName(e)},normalizeValue:W,normalizeOptions:function(e,t,n,o){const i={...e.dataset},a={},r={};return Q(i).forEach(e=>{const t=o&&e.includes(o)?e.replace(o,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;r[t]=W(i[e])}),Q(n).forEach(e=>{n[e]=W(n[e])}),Q(t).forEach(e=>{a[e]=e in n?n[e]:e in r?r[e]:t[e]}),a},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(`${t} ${e}`)}},reflow:e=>e.offsetHeight,focus:e=>e.focus(),ArrayFrom:e=>Array.from(e),Float32ArrayFrom:e=>Float32Array.from(Array.from(e)),Float64ArrayFrom:e=>Float64Array.from(Array.from(e)),ObjectAssign:V,ObjectKeys:Q,ObjectValues:e=>Object.values(e),getBoundingClientRect:G,getDocument:$,getDocumentBody:function(e){return $(e).body},getDocumentElement:Y,getDocumentHead:function(e){return $(e).head},getElementStyle:O,setElementStyle:(e,t)=>{V(e.style,t)},hasAttribute:(e,t)=>e.hasAttribute(t),hasAttributeNS:(e,t,n)=>e.hasAttributeNS(n||null,t),getAttribute:(e,t)=>e.getAttribute(t),getAttributeNS:(e,t,n)=>e.getAttributeNS(n||null,t),setAttribute:(e,t,n)=>e.setAttribute(t,n),setAttributeNS:(e,t,n,o)=>e.setAttributeNS(o||null,t,n),removeAttribute:(e,t)=>e.removeAttribute(t),removeAttributeNS:(e,t,n)=>e.removeAttributeNS(n||null,t),Version:"0.3.0alpha4"};export{ee as default}; |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.3.0alpha3 | dnp_theme © 2022 | MIT-License | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SHORTER=t()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",r="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",s="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",c=navigator.userAgentData,l=navigator.userAgent,m=/iPhone|iPad|iPod|Android/i,d=c?c.brands.some((function(e){return m.test(e.brand)})):m.test(l),f=/(iPhone|iPod|iPad)/,v=c?c.brands.some((function(e){return f.test(e.brand)})):f.test(l),g=!!l&&l.includes("Firefox"),p="webkitPerspective"in document.head.style||"perspective"in document.head.style;function E(e,t,n,i){var o=i||!1;e.addEventListener(t,n,o)}function y(e,t,n,i){var o=i||!1;e.removeEventListener(t,n,o)}function b(e,t,n,i){E(e,t,(function o(r){r.target===e&&(n.apply(e,[r]),y(e,t,o,i))}),i)}var h=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0}});b(document,"DOMContentLoaded",(function(){}),t)}catch(e){throw Error("Passive events are not supported")}return e}(),w="webkitTransform"in document.head.style||"transform"in document.head.style,A="ontouchstart"in window||"msMaxTouchPoints"in navigator,k="webkitAnimation"in document.head.style||"animation"in document.head.style,L="webkitTransition"in document.head.style||"transition"in document.head.style;function N(e,t){var n=[HTMLElement,Element,Node],i=t&&n.some((function(e){return t instanceof e}))?t:document;return n.some((function(t){return e instanceof t}))?e:i.querySelector(e)}var T=new Map,D={set:function(e,t,n){var i=N(e);i&&(T.has(t)||T.set(t,new Map),T.get(t).set(i,n))},getAllFor:function(e){var t=T.get(e);return t||null},get:function(e,t){var n=N(e),i=D.getAllFor(t),o=n&&i&&i.get(n);return o||null},remove:function(e,t){var n=N(e),i=T.get(t);i&&n&&(i.delete(n),0===i.size&&T.delete(t))}};function S(e,t){var n=getComputedStyle(e);return t in n?n[t]:""}function M(e){var t=S(e,"animationName"),n=S(e,"animationDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function C(e){var t=S(e,"animationName"),n=S(e,"animationDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function O(e){var t=S(e,i),o=S(e,n),r=o.includes("ms")?1:1e3,a=k&&t&&"none"!==t?parseFloat(o)*r:0;return Number.isNaN(a)?0:a}function z(e){var n=S(e,i),o=S(e,t),r=o.includes("ms")?1:1e3,a=k&&n&&"none"!==n?parseFloat(o)*r:0;return Number.isNaN(a)?0:a}function H(e){var t=S(e,"transitionProperty"),n=S(e,"transitionDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function P(e){var t=S(e,"transitionProperty"),n=S(e,"transitionDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function I(e){var t=S(e,s),n=S(e,a),i=n.includes("ms")?1:1e3,o=L&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function x(e){var t=S(e,s),n=S(e,r),i=n.includes("ms")?1:1e3,o=L&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function B(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}var F=function(e){return Object.keys(e)};var R=function(e,t){return Object.assign(e,t)},W=!!h&&{passive:!0},j=new Map;var Q=function(e){return e instanceof HTMLElement};function V(e,t){var n=e.getBoundingClientRect(),i=1,o=1;return t&&Q(e)&&(i=e.offsetWidth>0&&Math.round(n.width)/e.offsetWidth||1,o=e.offsetHeight>0&&Math.round(n.height)/e.offsetHeight||1),{width:n.width/i,height:n.height/o,top:n.top/o,right:n.right/i,bottom:n.bottom/o,left:n.left/i,x:n.left/i,y:n.top/o}}function q(e){return((e instanceof Node?e.ownerDocument:e.document)||window.document).documentElement}var U=function(e){return["TABLE","TD","TH"].includes(e.tagName)},G=function(e){return e instanceof(self||window).ShadowRoot||e instanceof ShadowRoot};function Y(e){return"HTML"===e.nodeName?e:e.assignedSlot||e.parentNode||(G(e)?e.host:null)||q(e)}function K(e){return[self,window].includes(e)}function X(e){if(null==e)return window;if(!K(e)){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Z(e){var t=getComputedStyle(e),n=t.transform,i=t.perspective,o=t.contain,r=t.willChange,a=t.filter;return"none"!==n||"none"!==i||"paint"===o||["transform","perspective"].includes(r)||g&&"filter"===r||g&&!!a&&"none"!==a}function J(e){return Q(e)&&"fixed"!==S(e,"position")?e.offsetParent:null}function $(e){var t=V(e);return Math.round(t.width)!==e.offsetWidth||Math.round(t.height)!==e.offsetHeight}return{ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:i,animationEndEvent:"animationend",animationEndEventLegacy:o,transitionDuration:"transitionDuration",transitionDurationLegacy:r,transitionDelay:"transitionDelay",transitionDelayLegacy:a,transitionEndEvent:"transitionend",transitionEndEventLegacy:u,transitionProperty:"transitionProperty",transitionPropertyLegacy:s,isMobile:d,isApple:v,isFirefox:g,support3DTransform:p,supportPassive:h,supportTransform:w,supportTouch:A,supportAnimation:k,supportTransition:L,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:c,userAgent:l,addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:E,off:y,one:b,Data:D,Timer:{set:function(e,t,n,i){var o=N(e);o&&(i&&i.length?(j.has(o)||j.set(o,new Map),j.get(o).set(i,setTimeout(t,n))):j.set(o,setTimeout(t,n)))},get:function(e,t){var n=N(e);if(!n)return null;if(t&&t.length){j.has(n)||j.set(n,new Map);var i=j.get(n);if(i.has(t))return i.get(t)}else if(j.has(n))return j.get(n);return null},clear:function(e,t){var n=N(e),i=n&&j.get(n);i&&(t&&t.length?i.has(t)&&(clearTimeout(i.get(t)),i.delete(t)):(clearTimeout(i),j.delete(n)))}},getInstance:function(e,t){return D.get(e,t)},emulateAnimationEnd:function(e,t){var n=0,i=new Event("animationend"),o=C(e),r=M(e);if(o){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",a),n=1)};e.addEventListener("animationend",a),setTimeout((function(){n||e.dispatchEvent(i)}),o+r+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){var n=0,i=new Event(o),r=z(e),a=O(e);if(k&&r){var u=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(o,u),n=1)};e.addEventListener(o,u),setTimeout((function(){n||e.dispatchEvent(i)}),r+a+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){var n=0,i=new Event("transitionend"),o=P(e),r=H(e);if(o){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",a),n=1)};e.addEventListener("transitionend",a),setTimeout((function(){n||e.dispatchEvent(i)}),o+r+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){var n=0,i=new Event(u),o=x(e),r=I(e);if(L&&o){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(u,a),n=1)};e.addEventListener(u,a),setTimeout((function(){n||e.dispatchEvent(i)}),o+r+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){var t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){var t=V(e,!0);return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:W,getElementAnimationDuration:C,getElementAnimationDurationLegacy:z,getElementAnimationDelay:M,getElementAnimationDelayLegacy:O,getElementTransitionDuration:P,getElementTransitionDurationLegacy:x,getElementTransitionDelay:H,getElementTransitionDelayLegacy:I,getNodeScroll:function(e){var t="scrollX"in e;return{x:t?e.scrollX:e.scrollLeft,y:t?e.scrollY:e.scrollTop}},getOffsetParent:function(e){for(var t=X(e),n=J(e);n&&U(n)&&"static"===S(n,"position");)n=J(n);return n&&["HTML","BODY"].includes(n.tagName)&&"static"===S(n,"position")&&!Z(n)?t:n||function(e){for(var t=Y(e);Q(t)&&!["HTML","BODY"].includes(t.nodeName);){if(Z(t))return t;t=t.parentNode}return null}(e)||t},getParentNode:Y,getRectRelativeToOffsetParent:function(e,t,n){var i=Q(t),o=V(e,i&&$(t)),r={x:0,y:0};if(i){var a=V(t,!0);r.x=a.x+t.clientLeft,r.y=a.y+t.clientTop}return{x:o.left+n.x-r.x,y:o.top+n.y-r.y,width:o.width,height:o.height}},getWindow:X,isArray:function(e){return Array.isArray(e)},isString:function(e){return"string"==typeof e},isElement:function(e){return e instanceof Element},isNode:function(e){return e instanceof Node},isHTMLElement:Q,isHTMLImageElement:function(e){return e instanceof HTMLImageElement},isSVGElement:function(e){return e instanceof SVGElement},isNodeList:function(e){return e instanceof NodeList},isHTMLCollection:function(e){return e instanceof HTMLCollection},isScaledElement:$,isTableElement:U,isShadowRoot:G,isElementsArray:function(e){return Array.isArray(e)&&e.every((function(e){return Q(e)}))},isWindow:K,isMedia:function(e){return e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(t){return e instanceof t}))},isRTL:function(){return[document.body,document.documentElement].some((function(e){return"rtl"===e.dir}))},closest:function(e,t){return e&&t?e.closest(t):null},querySelector:N,getCustomElements:function(e){var t=e&&Q(e)?e:document;return[].concat(t.querySelectorAll("*")).filter((function(e){return customElements.get(e.nodeName.toLowerCase())}))},querySelectorAll:function(e,t){return(t&&[HTMLElement,Element,Node].some((function(e){return t instanceof e}))?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&Q(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&Q(t)?t:document).getElementsByTagName(e)},normalizeValue:B,normalizeOptions:function(e,t,n,i){var o=Object.assign({},e.dataset),r={},a={};return F(o).forEach((function(e){var t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[t]=B(o[e])})),F(n).forEach((function(e){n[e]=B(n[e])})),F(t).forEach((function(e){r[e]=e in n?n[e]:e in a?a[e]:t[e]})),r},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(t+" "+e)}},reflow:function(e){return e.offsetHeight},focus:function(e){return e.focus()},ArrayFrom:function(e){return Array.from(e)},Float32ArrayFrom:function(e){return Float32Array.from(Array.from(e))},Float64ArrayFrom:function(e){return Float64Array.from(Array.from(e))},ObjectAssign:R,ObjectKeys:F,ObjectValues:function(e){return Object.values(e)},getBoundingClientRect:V,getDocumentElement:q,getElementStyle:S,setElementStyle:function(e,t){R(e.style,t)},hasAttribute:function(e,t){return e.hasAttribute(t)},hasAttributeNS:function(e,t,n){return e.hasAttributeNS(n||null,t)},getAttribute:function(e,t){return e.getAttribute(t)},getAttributeNS:function(e,t,n){return e.getAttributeNS(n||null,t)},setAttribute:function(e,t,n){return e.setAttribute(t,n)},setAttributeNS:function(e,t,n,i){return e.setAttributeNS(i||null,t,n)},removeAttribute:function(e,t){return e.removeAttribute(t)},removeAttributeNS:function(e,t,n){return e.removeAttributeNS(n||null,t)},Version:"0.3.0alpha3"}})); | ||
// shorter-js v0.3.0alpha4 | dnp_theme © 2022 | MIT-License | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SHORTER=t()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",r="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",s="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",c=navigator.userAgentData,l=navigator.userAgent,m=/iPhone|iPad|iPod|Android/i,d=c?c.brands.some((function(e){return m.test(e.brand)})):m.test(l),f=/(iPhone|iPod|iPad)/,v=c?c.brands.some((function(e){return f.test(e.brand)})):f.test(l),g=!!l&&l.includes("Firefox"),E="webkitPerspective"in document.head.style||"perspective"in document.head.style;function y(e,t,n,i){var o=i||!1;e.addEventListener(t,n,o)}function b(e,t,n,i){var o=i||!1;e.removeEventListener(t,n,o)}function p(e,t,n,i){y(e,t,(function o(r){r.target===e&&(n.apply(e,[r]),b(e,t,o,i))}),i)}var h=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0}});p(document,"DOMContentLoaded",(function(){}),t)}catch(e){throw Error("Passive events are not supported")}return e}(),w="webkitTransform"in document.head.style||"transform"in document.head.style,A="ontouchstart"in window||"msMaxTouchPoints"in navigator,k="webkitAnimation"in document.head.style||"animation"in document.head.style,L="webkitTransition"in document.head.style||"transition"in document.head.style;function D(e,t){var n=[HTMLElement,Element,Node],i=t&&n.some((function(e){return t instanceof e}))?t:document;return n.some((function(t){return e instanceof t}))?e:i.querySelector(e)}var T=new Map,N={set:function(e,t,n){var i=D(e);i&&(T.has(t)||T.set(t,new Map),T.get(t).set(i,n))},getAllFor:function(e){var t=T.get(e);return t||null},get:function(e,t){var n=D(e),i=N.getAllFor(t),o=n&&i&&i.get(n);return o||null},remove:function(e,t){var n=D(e),i=T.get(t);i&&n&&(i.delete(n),0===i.size&&T.delete(t))}};function S(e,t){var n=getComputedStyle(e);return t in n?n[t]:""}function M(e){var t=S(e,"animationName"),n=S(e,"animationDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function C(e){var t=S(e,"animationName"),n=S(e,"animationDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function O(e){var t=S(e,i),o=S(e,n),r=o.includes("ms")?1:1e3,a=k&&t&&"none"!==t?parseFloat(o)*r:0;return Number.isNaN(a)?0:a}function z(e){var n=S(e,i),o=S(e,t),r=o.includes("ms")?1:1e3,a=k&&n&&"none"!==n?parseFloat(o)*r:0;return Number.isNaN(a)?0:a}function H(e){var t=S(e,"transitionProperty"),n=S(e,"transitionDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function I(e){var t=S(e,"transitionProperty"),n=S(e,"transitionDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function P(e){var t=S(e,s),n=S(e,a),i=n.includes("ms")?1:1e3,o=L&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function x(e){var t=S(e,s),n=S(e,r),i=n.includes("ms")?1:1e3,o=L&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function F(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}var B=function(e){return Object.keys(e)};var R=function(e,t){return Object.assign(e,t)},W=!!h&&{passive:!0},j=new Map;var Q=function(e){return e instanceof HTMLElement};function V(e,t){var n=e.getBoundingClientRect(),i=n.width,o=n.height,r=n.top,a=n.right,u=n.bottom,s=n.left,c=1,l=1;return t&&Q(e)&&(c=e.offsetWidth>0&&Math.round(i)/e.offsetWidth||1,l=e.offsetHeight>0&&Math.round(o)/e.offsetHeight||1),{width:i/c,height:o/l,top:r/l,right:a/c,bottom:u/l,left:s/c,x:s/c,y:r/l}}function q(e){return e instanceof Window}var U=function(e){return e instanceof Node};function G(e){return U(e)?e.ownerDocument:q(e)?e.document:window.document}function K(e){return G(e).documentElement}function X(e){if(null==e)return window;if(!q(e)){var t=e.ownerDocument;return t&&t.defaultView||window}return e}var Y=function(e){return e instanceof X(e).ShadowRoot||e instanceof ShadowRoot};function Z(e){var t=V(e);return Math.round(t.width)!==e.offsetWidth||Math.round(t.height)!==e.offsetHeight}return{ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:i,animationEndEvent:"animationend",animationEndEventLegacy:o,transitionDuration:"transitionDuration",transitionDurationLegacy:r,transitionDelay:"transitionDelay",transitionDelayLegacy:a,transitionEndEvent:"transitionend",transitionEndEventLegacy:u,transitionProperty:"transitionProperty",transitionPropertyLegacy:s,isMobile:d,isApple:v,isFirefox:g,support3DTransform:E,supportPassive:h,supportTransform:w,supportTouch:A,supportAnimation:k,supportTransition:L,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:c,userAgent:l,addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:y,off:b,one:p,Data:N,Timer:{set:function(e,t,n,i){var o=D(e);o&&(i&&i.length?(j.has(o)||j.set(o,new Map),j.get(o).set(i,setTimeout(t,n))):j.set(o,setTimeout(t,n)))},get:function(e,t){var n=D(e);if(!n)return null;if(t&&t.length){j.has(n)||j.set(n,new Map);var i=j.get(n);if(i.has(t))return i.get(t)}else if(j.has(n))return j.get(n);return null},clear:function(e,t){var n=D(e),i=n&&j.get(n);i&&(t&&t.length?i.has(t)&&(clearTimeout(i.get(t)),i.delete(t)):(clearTimeout(i),j.delete(n)))}},getInstance:function(e,t){return N.get(e,t)},emulateAnimationEnd:function(e,t){var n=0,i=new Event("animationend"),o=C(e),r=M(e);if(o){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",a),n=1)};e.addEventListener("animationend",a),setTimeout((function(){n||e.dispatchEvent(i)}),o+r+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){var n=0,i=new Event(o),r=z(e),a=O(e);if(k&&r){var u=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(o,u),n=1)};e.addEventListener(o,u),setTimeout((function(){n||e.dispatchEvent(i)}),r+a+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){var n=0,i=new Event("transitionend"),o=I(e),r=H(e);if(o){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",a),n=1)};e.addEventListener("transitionend",a),setTimeout((function(){n||e.dispatchEvent(i)}),o+r+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){var n=0,i=new Event(u),o=x(e),r=P(e);if(L&&o){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(u,a),n=1)};e.addEventListener(u,a),setTimeout((function(){n||e.dispatchEvent(i)}),o+r+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){var t=V(e),n=t.top,i=t.bottom;return n<=K(e).clientHeight&&i>=0},isElementInViewport:function(e){var t=V(e,!0);return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:W,getElementAnimationDuration:C,getElementAnimationDurationLegacy:z,getElementAnimationDelay:M,getElementAnimationDelayLegacy:O,getElementTransitionDuration:I,getElementTransitionDurationLegacy:x,getElementTransitionDelay:H,getElementTransitionDelayLegacy:P,getNodeScroll:function(e){var t="scrollX"in e;return{x:t?e.scrollX:e.scrollLeft,y:t?e.scrollY:e.scrollTop}},getParentNode:function(e){return"HTML"===e.nodeName?e:e.assignedSlot||e.parentNode||(Y(e)?e.host:null)||K(e)},getRectRelativeToOffsetParent:function(e,t,n){var i=Q(t),o=V(e,i&&Z(t)),r={x:0,y:0};if(i){var a=V(t,!0);r.x=a.x+t.clientLeft,r.y=a.y+t.clientTop}return{x:o.left+n.x-r.x,y:o.top+n.y-r.y,width:o.width,height:o.height}},getWindow:X,isArray:function(e){return Array.isArray(e)},isString:function(e){return"string"==typeof e},isElement:function(e){return e instanceof Element},isNode:U,isHTMLElement:Q,isHTMLImageElement:function(e){return e instanceof HTMLImageElement},isSVGElement:function(e){return e instanceof SVGElement},isNodeList:function(e){return e instanceof NodeList},isHTMLCollection:function(e){return e instanceof HTMLCollection},isScaledElement:Z,isTableElement:function(e){return["TABLE","TD","TH"].includes(e.tagName)},isShadowRoot:Y,isElementsArray:function(e){return Array.isArray(e)&&e.every((function(e){return Q(e)}))},isWindow:q,isMedia:function(e){return e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(t){return e instanceof t}))},isRTL:function(e){return"rtl"===K(e).dir},closest:function(e,t){return e&&t?e.closest(t):null},querySelector:D,getCustomElements:function(e){var t=e&&Q(e)?e:document;return[].concat(t.querySelectorAll("*")).filter((function(e){return customElements.get(e.nodeName.toLowerCase())}))},querySelectorAll:function(e,t){return(t&&[HTMLElement,Element,Node].some((function(e){return t instanceof e}))?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&Q(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&Q(t)?t:document).getElementsByTagName(e)},normalizeValue:F,normalizeOptions:function(e,t,n,i){var o=Object.assign({},e.dataset),r={},a={};return B(o).forEach((function(e){var t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[t]=F(o[e])})),B(n).forEach((function(e){n[e]=F(n[e])})),B(t).forEach((function(e){r[e]=e in n?n[e]:e in a?a[e]:t[e]})),r},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(t+" "+e)}},reflow:function(e){return e.offsetHeight},focus:function(e){return e.focus()},ArrayFrom:function(e){return Array.from(e)},Float32ArrayFrom:function(e){return Float32Array.from(Array.from(e))},Float64ArrayFrom:function(e){return Float64Array.from(Array.from(e))},ObjectAssign:R,ObjectKeys:B,ObjectValues:function(e){return Object.values(e)},getBoundingClientRect:V,getDocument:G,getDocumentBody:function(e){return G(e).body},getDocumentElement:K,getDocumentHead:function(e){return G(e).head},getElementStyle:S,setElementStyle:function(e,t){R(e.style,t)},hasAttribute:function(e,t){return e.hasAttribute(t)},hasAttributeNS:function(e,t,n){return e.hasAttributeNS(n||null,t)},getAttribute:function(e,t){return e.getAttribute(t)},getAttributeNS:function(e,t,n){return e.getAttributeNS(n||null,t)},setAttribute:function(e,t,n){return e.setAttribute(t,n)},setAttributeNS:function(e,t,n,i){return e.setAttributeNS(i||null,t,n)},removeAttribute:function(e,t){return e.removeAttribute(t)},removeAttributeNS:function(e,t,n){return e.removeAttributeNS(n||null,t)},Version:"0.3.0alpha4"}})); |
{ | ||
"name": "shorter-js", | ||
"version": "0.3.0alpha3", | ||
"version": "0.3.0alpha4", | ||
"description": "A small ES6+ library with various JavaScript tools useful for creating light libraries.", | ||
@@ -5,0 +5,0 @@ "main": "dist/shorter-js.min.js", |
@@ -13,3 +13,5 @@ import isHTMLElement from '../is/isHTMLElement'; | ||
export default function getBoundingClientRect(element, includeScale) { | ||
const clientRect = element.getBoundingClientRect(); | ||
const { | ||
width, height, top, right, bottom, left, | ||
} = element.getBoundingClientRect(); | ||
let scaleX = 1; | ||
@@ -20,17 +22,17 @@ let scaleY = 1; | ||
scaleX = element.offsetWidth > 0 | ||
? Math.round(clientRect.width) / element.offsetWidth || 1 : 1; | ||
? Math.round(width) / element.offsetWidth || 1 : 1; | ||
scaleY = element.offsetHeight > 0 | ||
? Math.round(clientRect.height) / element.offsetHeight || 1 : 1; | ||
? Math.round(height) / element.offsetHeight || 1 : 1; | ||
} | ||
return { | ||
width: clientRect.width / scaleX, | ||
height: clientRect.height / scaleY, | ||
top: clientRect.top / scaleY, | ||
right: clientRect.right / scaleX, | ||
bottom: clientRect.bottom / scaleY, | ||
left: clientRect.left / scaleX, | ||
x: clientRect.left / scaleX, | ||
y: clientRect.top / scaleY, | ||
width: width / scaleX, | ||
height: height / scaleY, | ||
top: top / scaleY, | ||
right: right / scaleX, | ||
bottom: bottom / scaleY, | ||
left: left / scaleX, | ||
x: left / scaleX, | ||
y: top / scaleY, | ||
}; | ||
} |
@@ -0,10 +1,11 @@ | ||
import getDocument from './getDocument'; | ||
/** | ||
* Returns the `document.documentElement` or the `<html>` element. | ||
* @see https://github.com/floating-ui/floating-ui | ||
* @param {Node | Window} node | ||
* | ||
* @param {(Node | HTMLElement | Element)=} node | ||
* @returns {HTMLElement} | ||
*/ | ||
export default function getDocumentElement(node) { | ||
const doc = (node instanceof Node ? node.ownerDocument : node.document) || window.document; | ||
return doc.documentElement; | ||
return getDocument(node).documentElement; | ||
} |
@@ -10,8 +10,8 @@ import isHTMLElement from '../is/isHTMLElement'; | ||
* @param {HTMLElement} element target | ||
* @param {HTMLElement} offsetParent the container / offset parent | ||
* @param {HTMLElement | globalThis} offsetParent the container / offset parent | ||
* @param {{x: number, y: number}} scroll | ||
* @returns {Record<string, number>} | ||
* @returns {Partial<SHORTER.BoundingClientRect>} | ||
*/ | ||
export default function getRectRelativeToOffsetParent(element, offsetParent, scroll) { | ||
const isParentAnElement = isHTMLElement(offsetParent); | ||
const isParentAnElement = isHTMLElement(offsetParent); // @ts-ignore -- `isParentAnElement` checks | ||
const rect = getBoundingClientRect(element, isParentAnElement && isScaledElement(offsetParent)); | ||
@@ -21,4 +21,7 @@ const offsets = { x: 0, y: 0 }; | ||
if (isParentAnElement) { | ||
// @ts-ignore -- `isParentAnElement` checks | ||
const offsetRect = getBoundingClientRect(offsetParent, true); | ||
// @ts-ignore -- `isParentAnElement` checks | ||
offsets.x = offsetRect.x + offsetParent.clientLeft; | ||
// @ts-ignore -- `isParentAnElement` checks | ||
offsets.y = offsetRect.y + offsetParent.clientTop; | ||
@@ -25,0 +28,0 @@ } |
@@ -7,4 +7,4 @@ import isWindow from '../is/isWindow'; | ||
* | ||
* @param {(Node | Element | Window)=} node target node | ||
* @returns {Window} the `Window` object | ||
* @param {(Node | Element | HTMLElement | Window)=} node target node | ||
* @returns {globalThis} the `Window` object | ||
*/ | ||
@@ -22,4 +22,4 @@ export default function getWindow(node) { | ||
// @ts-ignore | ||
// @ts-ignore -- we know it's window, we checked above | ||
return node; | ||
} |
@@ -178,3 +178,6 @@ // strings | ||
import getBoundingClientRect from './get/getBoundingClientRect'; | ||
import getDocument from './get/getDocument'; | ||
import getDocumentBody from './get/getDocumentBody'; | ||
import getDocumentElement from './get/getDocumentElement'; | ||
import getDocumentHead from './get/getDocumentHead'; | ||
import getElementAnimationDuration from './get/getElementAnimationDuration'; | ||
@@ -190,3 +193,2 @@ import getElementAnimationDurationLegacy from './get/getElementAnimationDurationLegacy'; | ||
import getNodeScroll from './get/getNodeScroll'; | ||
import getOffsetParent from './get/getOffsetParent'; | ||
import getParentNode from './get/getParentNode'; | ||
@@ -369,3 +371,2 @@ import getRectRelativeToOffsetParent from './get/getRectRelativeToOffsetParent'; | ||
getNodeScroll, | ||
getOffsetParent, | ||
getParentNode, | ||
@@ -408,3 +409,6 @@ getRectRelativeToOffsetParent, | ||
getBoundingClientRect, | ||
getDocument, | ||
getDocumentBody, | ||
getDocumentElement, | ||
getDocumentHead, | ||
getElementStyle, | ||
@@ -411,0 +415,0 @@ setElementStyle, |
@@ -0,1 +1,4 @@ | ||
import getBoundingClientRect from '../get/getBoundingClientRect'; | ||
import getDocumentElement from '../get/getDocumentElement'; | ||
/** | ||
@@ -9,7 +12,8 @@ * Utility to determine if an `HTMLElement` | ||
const isElementInScrollRange = (element) => { | ||
const bcr = element.getBoundingClientRect(); | ||
const viewportHeight = window.innerHeight || document.documentElement.clientHeight; | ||
return bcr.top <= viewportHeight && bcr.bottom >= 0; // bottom && top | ||
const { top, bottom } = getBoundingClientRect(element); | ||
const html = getDocumentElement(element); | ||
// checks bottom && top | ||
return top <= html.clientHeight && bottom >= 0; | ||
}; | ||
export default isElementInScrollRange; |
@@ -0,9 +1,9 @@ | ||
import getDocumentElement from '../get/getDocumentElement'; | ||
/** | ||
* Checks if a page is Right To Left. | ||
* @param {HTMLElement} node the target | ||
* @returns {boolean} the query result | ||
*/ | ||
const isRTL = () => [ | ||
document.body, | ||
document.documentElement, | ||
].some((el) => el.dir === 'rtl'); | ||
const isRTL = (node) => getDocumentElement(node).dir === 'rtl'; | ||
export default isRTL; |
@@ -0,1 +1,2 @@ | ||
import getWindow from '../get/getWindow'; | ||
/** | ||
@@ -8,6 +9,5 @@ * Check if target is a `ShadowRoot`. | ||
const isShadowRoot = (element) => { | ||
// eslint-disable-next-line no-restricted-globals | ||
const OwnElement = (self || window).ShadowRoot; | ||
const OwnElement = getWindow(element).ShadowRoot; | ||
return element instanceof OwnElement || element instanceof ShadowRoot; | ||
}; | ||
export default isShadowRoot; |
@@ -8,4 +8,3 @@ /** | ||
export default function isWindow(node) { | ||
// eslint-disable-next-line no-restricted-globals | ||
return [self, window].includes(node); | ||
return node instanceof Window; | ||
} |
@@ -128,3 +128,6 @@ export as namespace SHORTER; | ||
export { default as getBoundingClientRect } from "shorter-js/src/get/getBoundingClientRect"; | ||
export { default as getDocument } from "shorter-js/src/get/getDocument"; | ||
export { default as getDocumentBody } from "shorter-js/src/get/getDocumentBody"; | ||
export { default as getDocumentElement } from "shorter-js/src/get/getDocumentElement"; | ||
export { default as getDocumentHead } from "shorter-js/src/get/getDocumentHead"; | ||
export { default as getElementAnimationDuration } from "shorter-js/src/get/getElementAnimationDuration"; | ||
@@ -140,3 +143,2 @@ export { default as getElementAnimationDurationLegacy } from "shorter-js/src/get/getElementAnimationDurationLegacy"; | ||
export { default as getNodeScroll } from "shorter-js/src/get/getNodeScroll"; | ||
export { default as getOffsetParent } from "shorter-js/src/get/getOffsetParent"; | ||
export { default as getParentNode } from "shorter-js/src/get/getParentNode"; | ||
@@ -143,0 +145,0 @@ export { default as getRectRelativeToOffsetParent } from "shorter-js/src/get/getRectRelativeToOffsetParent"; |
@@ -145,3 +145,6 @@ // strings | ||
export { default as getBoundingClientRect } from '../../src/get/getBoundingClientRect'; | ||
export { default as getDocument } from '../../src/get/getDocument'; | ||
export { default as getDocumentBody } from '../../src/get/getDocumentBody'; | ||
export { default as getDocumentElement } from '../../src/get/getDocumentElement'; | ||
export { default as getDocumentHead } from '../../src/get/getDocumentHead'; | ||
export { default as getElementAnimationDuration } from "../../src/get/getElementAnimationDuration"; | ||
@@ -157,3 +160,2 @@ export { default as getElementAnimationDurationLegacy } from "../../src/get/getElementAnimationDurationLegacy"; | ||
export { default as getNodeScroll } from "../../src/get/getNodeScroll"; | ||
export { default as getOffsetParent } from "../../src/get/getOffsetParent"; | ||
export { default as getParentNode } from "../../src/get/getParentNode"; | ||
@@ -160,0 +162,0 @@ export { default as getRectRelativeToOffsetParent } from "../../src/get/getRectRelativeToOffsetParent"; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
209
345848
8796