shorter-js
Advanced tools
Comparing version 0.2.23 to 0.2.24
/*! | ||
* shorter-js v0.2.23 (https://github.com/thednp/shorter-js) | ||
* Copyright 2019-2021 © dnp_theme | ||
* shorter-js v0.2.24 (https://github.com/thednp/shorter-js) | ||
* Copyright 2019-2022 © dnp_theme | ||
* Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
@@ -579,2 +579,8 @@ */ | ||
*/ | ||
const animationDuration$1 = 'animationDuration'; | ||
/** | ||
* A global namespace for 'animationDuration' string. | ||
* @type {string} | ||
*/ | ||
const animationDuration = 'webkitAnimation' in document.head.style ? 'webkitAnimationDuration' : 'animationDuration'; | ||
@@ -586,2 +592,8 @@ | ||
*/ | ||
const animationDelay$1 = 'animationDelay'; | ||
/** | ||
* A global namespace for 'animationDelay' string. | ||
* @type {string} | ||
*/ | ||
const animationDelay = 'webkitAnimation' in document.head.style ? 'webkitAnimationDelay' : 'animationDelay'; | ||
@@ -593,2 +605,8 @@ | ||
*/ | ||
const animationName$1 = 'animationName'; | ||
/** | ||
* A global namespace for 'animationName' string. | ||
* @type {string} | ||
*/ | ||
const animationName = 'webkitAnimation' in document.head.style ? 'webkitAnimationName' : 'animationName'; | ||
@@ -600,2 +618,8 @@ | ||
*/ | ||
const animationEndEvent$1 = 'animationend'; | ||
/** | ||
* A global namespace for 'animationend' string. | ||
* @type {string} | ||
*/ | ||
const animationEndEvent = 'webkitAnimation' in document.head.style ? 'webkitAnimationEnd' : 'animationend'; | ||
@@ -607,2 +631,8 @@ | ||
*/ | ||
const transitionDuration$1 = 'transitionDuration'; | ||
/** | ||
* A global namespace for 'transitionDuration' string. | ||
* @type {string} | ||
*/ | ||
const transitionDuration = 'webkitTransition' in document.head.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
@@ -614,2 +644,8 @@ | ||
*/ | ||
const transitionDelay$1 = 'transitionDelay'; | ||
/** | ||
* A global namespace for 'transitionDelay' string. | ||
* @type {string} | ||
*/ | ||
const transitionDelay = 'webkitTransition' in document.head.style ? 'webkitTransitionDelay' : 'transitionDelay'; | ||
@@ -621,2 +657,8 @@ | ||
*/ | ||
const transitionEndEvent$1 = 'transitionend'; | ||
/** | ||
* A global namespace for 'transitionend' string. | ||
* @type {string} | ||
*/ | ||
const transitionEndEvent = 'webkitTransition' in document.head.style ? 'webkitTransitionEnd' : 'transitionend'; | ||
@@ -628,2 +670,8 @@ | ||
*/ | ||
const transitionProperty$1 = 'transitionProperty'; | ||
/** | ||
* A global namespace for 'transitionProperty' string. | ||
* @type {string} | ||
*/ | ||
const transitionProperty = 'webkitTransition' in document.head.style ? 'webkitTransitionProperty' : 'transitionProperty'; | ||
@@ -700,9 +748,15 @@ | ||
/** | ||
* A global namespace for `userAgentData` event. | ||
* @type {string} | ||
*/ | ||
const userAgentData = 'userAgentData'; | ||
const mobileBrands = /iPhone|iPad|iPod|Android/i; | ||
const userAgentStr = 'userAgentData'; | ||
let isMobileCheck = false; | ||
if (navigator[userAgentStr]) { | ||
isMobileCheck = navigator[userAgentStr].brands.some((x) => mobileBrands.test(x.brand)); | ||
// @ts-ignore | ||
if (navigator[userAgentData]) { | ||
// @ts-ignore | ||
isMobileCheck = navigator[userAgentData].brands.some((x) => mobileBrands.test(x.brand)); | ||
} else { | ||
@@ -718,15 +772,16 @@ isMobileCheck = mobileBrands.test(navigator.userAgent); | ||
/** @type {Record<string, any>} */ | ||
// @ts-ignore | ||
const { userAgentData } = navigator; | ||
const agentData = navigator[userAgentData]; | ||
const appleBrands = /(iPhone|iPod|iPad)/; | ||
/** | ||
* A global namespace for Apple browsers. | ||
* A global boolean for Apple browsers. | ||
* @type {boolean} | ||
*/ | ||
const isApple = !userAgentData ? appleBrands.test(navigator.userAgent) | ||
: userAgentData.brands.some((x) => appleBrands.test(x.brand)); | ||
const isApple = !agentData ? appleBrands.test(navigator.userAgent) | ||
: agentData.brands.some((/** @type {Record<string, any>} */x) => appleBrands.test(x.brand)); | ||
/** | ||
* A global namespace for CSS3 3D transform support. | ||
* A global `boolean` for CSS3 3D transform support. | ||
* @type {boolean} | ||
@@ -737,2 +792,51 @@ */ | ||
/** | ||
* Add eventListener to an `HTMLElement` | `Document` target. | ||
* | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
function on(element, eventName, handler, options) { | ||
const ops = options || false; | ||
element.addEventListener(eventName, handler, ops); | ||
} | ||
/** | ||
* Remove eventListener from an `HTMLElement` | `Document` target. | ||
* | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
function off(element, eventName, handler, options) { | ||
const ops = options || false; | ||
element.removeEventListener(eventName, handler, ops); | ||
} | ||
/** | ||
* Add an `eventListener` to an `HTMLElement` | `Document` target | ||
* and remove it once callback is called. | ||
* | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
function one(element, eventName, handler, options) { | ||
/** | ||
* Wrap the handler for easy on -> off | ||
* @param {Event} e the Event object | ||
*/ | ||
function handlerWrapper(e) { | ||
if (e.target === element) { | ||
handler.apply(element, [e]); | ||
off(element, eventName, handlerWrapper, options); | ||
} | ||
} | ||
on(element, eventName, handlerWrapper, options); | ||
} | ||
/** | ||
* A global namespace for passive events support. | ||
@@ -750,5 +854,3 @@ * @type {boolean} | ||
}); | ||
document[addEventListener]('DOMContentLoaded', function wrap() { | ||
document[removeEventListener]('DOMContentLoaded', wrap, opts); | ||
}, opts); | ||
one(document, DOMContentLoadedEvent, () => {}, opts); | ||
} catch (e) { | ||
@@ -774,3 +876,3 @@ throw Error('Passive events are not supported'); | ||
/** | ||
* A global namespace for CSS3 animation support. | ||
* A global `boolean` for CSS3 animation support. | ||
* @type {boolean} | ||
@@ -818,80 +920,31 @@ */ | ||
/** | ||
* Add eventListener to Element | ||
* Checks if an element is an `HTMLElement`. | ||
* | ||
* @param {Element} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
*/ | ||
function on(element, eventName, handler, options) { | ||
const ops = options || false; | ||
element.addEventListener(eventName, handler, ops); | ||
} | ||
/** | ||
* Remove eventListener from Element | ||
* | ||
* @param {Element} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
*/ | ||
function off(element, eventName, handler, options) { | ||
const ops = options || false; | ||
element.removeEventListener(eventName, handler, ops); | ||
} | ||
/** | ||
* Add an eventListener to Element | ||
* and remove it once callback is called. | ||
* | ||
* @param {Element} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
*/ | ||
function one(element, eventName, handler, options) { | ||
/** | ||
* Wrap the handler for easy on -> off | ||
* @param {Event} e the Event object | ||
*/ | ||
function handlerWrapper(e) { | ||
if (e.target === element) { | ||
handler.apply(element, [e]); | ||
off(element, eventName, handlerWrapper, options); | ||
} | ||
} | ||
on(element, eventName, handlerWrapper, options); | ||
} | ||
/** | ||
* Checks if an object is an `Element`. | ||
* | ||
* @param {any} element the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
function isElement(element) { | ||
return element instanceof Element; | ||
} | ||
const isHTMLElement = (element) => typeof element === 'object' && element instanceof HTMLElement; | ||
/** | ||
* Utility to check if target is typeof `Element` | ||
* Utility to check if target is typeof `HTMLElement` | ||
* or find one that matches a selector. | ||
* | ||
* @param {Element | string} selector the input selector or target element | ||
* @param {Element=} parent optional Element to look into | ||
* @return {Element?} the Element or `querySelector` result | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {(ParentNode | HTMLElement)=} parent optional `HTMLElement` to look into | ||
* @return {HTMLElement?} the `HTMLElement` or `querySelector` result | ||
*/ | ||
function querySelector(selector, parent) { | ||
const lookUp = parent && isElement(parent) ? parent : document; | ||
// @ts-ignore -- `isElement` is just as good | ||
return isElement(selector) ? selector : lookUp.querySelector(selector); | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return typeof selector === 'object' ? selector : lookUp.querySelector(selector); | ||
} | ||
const TimeCache = new Map(); | ||
/** | ||
* An interface for one or more `TimerHandler`s per `Element`. | ||
* @see https://github.com/thednp/navbar.js/ | ||
*/ | ||
const Timer = { | ||
/** | ||
* Sets a new timeout timer for an element, or element -> key association. | ||
* @param {Element | string} target target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {ReturnType<TimerHandler>} callback the callback | ||
@@ -903,5 +956,6 @@ * @param {number} delay the execution delay | ||
const element = querySelector(target); | ||
if (!isElement(element)) return; | ||
if (typeof key === 'string' && key.length) { | ||
if (!isHTMLElement(element)) return; | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
@@ -919,3 +973,3 @@ TimeCache.set(element, new Map()); | ||
* Returns the timer associated with the target. | ||
* @param {Element | string} target target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string=} key a unique | ||
@@ -926,5 +980,6 @@ * @returns {Map<Element, TimerHandler>?} the timer | ||
const element = querySelector(target); | ||
if (!isElement(element)) return null; | ||
if (typeof key === 'string' && key.length) { | ||
if (!isHTMLElement(element)) return null; | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
@@ -945,3 +1000,3 @@ TimeCache.set(element, new Map()); | ||
* Clears the element's timer. | ||
* @param {Element} target target element | ||
* @param {HTMLElement} target target element | ||
* @param {string=} key a unique | ||
@@ -952,5 +1007,5 @@ */ | ||
if (!isElement(element) || !TimeCache.has(element)) return; | ||
if (!isHTMLElement(element) || !TimeCache.has(element)) return; | ||
if (typeof key === 'string' && key.length) { | ||
if (key && key.length) { | ||
const keyTimers = TimeCache.get(element); | ||
@@ -977,9 +1032,9 @@ | ||
* Sets web components data. | ||
* @param {Element | string} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @param {any} instance the component instance | ||
*/ | ||
set: (element, component, instance) => { | ||
const ELEMENT = querySelector(element); | ||
if (!isElement(ELEMENT)) return; | ||
set: (target, component, instance) => { | ||
const element = querySelector(target); | ||
if (!isHTMLElement(element)) return; | ||
@@ -991,3 +1046,3 @@ if (!componentData.has(component)) { | ||
const instanceMap = componentData.get(component); | ||
instanceMap.set(ELEMENT, instance); | ||
instanceMap.set(element, instance); | ||
}, | ||
@@ -1009,12 +1064,12 @@ | ||
* Returns the instance associated with the target. | ||
* @param {Element | string} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any?} the instance | ||
*/ | ||
get: (element, component) => { | ||
const ELEMENT = querySelector(element); | ||
get: (target, component) => { | ||
const element = querySelector(target); | ||
const allForC = Data.getAllFor(component); | ||
if (allForC && isElement(ELEMENT) && allForC.has(ELEMENT)) { | ||
return allForC.get(ELEMENT); | ||
if (allForC && isHTMLElement(element) && allForC.has(element)) { | ||
return allForC.get(element); | ||
} | ||
@@ -1026,7 +1081,8 @@ return null; | ||
* Removes web components data. | ||
* @param {Element} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
*/ | ||
remove: (element, component) => { | ||
if (!componentData.has(component)) return; | ||
remove: (target, component) => { | ||
const element = querySelector(target); | ||
if (!componentData.has(component) || !element) return; | ||
@@ -1044,19 +1100,106 @@ const instanceMap = componentData.get(component); | ||
* An alias for `Data.get()`. | ||
* @param {Element | string} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any} the request result | ||
* @returns {Record<string, any>?} the request result | ||
*/ | ||
const getInstance = (element, component) => Data.get(element, component); | ||
const getInstance = (target, component) => Data.get(target, component); | ||
/** | ||
* Shortcut for `window.getComputedStyle(element).propertyName` | ||
* static method. | ||
* | ||
* * If `element` parameter is not an `HTMLElement`, `getComputedStyle` | ||
* throws a `ReferenceError`. | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {string=} property the css property | ||
* @return {string} the css property value | ||
*/ | ||
function getElementStyle(element, property) { | ||
const computedStyle = getComputedStyle(element); | ||
return property && property in computedStyle | ||
? computedStyle.getPropertyValue(property) | ||
: ''; | ||
} | ||
/** | ||
* Utility to get the computed `animationDelay` | ||
* from Element in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementAnimationDelay$1(element) { | ||
const propertyValue = getElementStyle(element, animationName$1); | ||
const durationValue = getElementStyle(element, animationDelay$1); | ||
const durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
const duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
return !Number.isNaN(duration) ? duration : 0; | ||
} | ||
/** | ||
* Utility to get the computed `animationDuration` | ||
* from `HTMLElement` in miliseconds. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementAnimationDuration$1(element) { | ||
const propertyValue = getElementStyle(element, animationName$1); | ||
const durationValue = getElementStyle(element, animationDuration$1); | ||
const durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
const duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
return !Number.isNaN(duration) ? duration : 0; | ||
} | ||
/** | ||
* Utility to make sure callbacks are consistently | ||
* called when animation ends. | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `animationend` callback | ||
*/ | ||
function emulateAnimationEnd$1(element, handler) { | ||
let called = 0; | ||
const endEvent = new Event(animationEndEvent$1); | ||
const duration = getElementAnimationDuration$1(element); | ||
const delay = getElementAnimationDelay$1(element); | ||
if (duration) { | ||
/** | ||
* Wrap the handler in on -> off callback | ||
* @param {Event} e Event object | ||
*/ | ||
const animationEndWrapper = (e) => { | ||
if (e.target === element) { | ||
handler.apply(element, [e]); | ||
element.removeEventListener(animationEndEvent$1, animationEndWrapper); | ||
called = 1; | ||
} | ||
}; | ||
element.addEventListener(animationEndEvent$1, animationEndWrapper); | ||
setTimeout(() => { | ||
if (!called) element.dispatchEvent(endEvent); | ||
}, duration + delay + 17); | ||
} else { | ||
handler.apply(element, [endEvent]); | ||
} | ||
} | ||
/** | ||
* Utility to get the computed `animationDelay` | ||
* from Element in miliseconds. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementAnimationDelay(element) { | ||
const computedStyle = getComputedStyle(element); | ||
const propertyValue = computedStyle[animationName]; | ||
const durationValue = computedStyle[animationDelay]; | ||
const propertyValue = getElementStyle(element, animationName); | ||
const durationValue = getElementStyle(element, animationDelay); | ||
const durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
@@ -1071,11 +1214,10 @@ const duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
* Utility to get the computed `animationDuration` | ||
* from Element in miliseconds. | ||
* from `HTMLElement` in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementAnimationDuration(element) { | ||
const computedStyle = getComputedStyle(element); | ||
const propertyValue = computedStyle[animationName]; | ||
const durationValue = computedStyle[animationDuration]; | ||
const propertyValue = getElementStyle(element, animationName); | ||
const durationValue = getElementStyle(element, animationDuration); | ||
const durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
@@ -1092,3 +1234,3 @@ const duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `animationend` callback | ||
@@ -1102,3 +1244,3 @@ */ | ||
if (duration) { | ||
if (supportAnimation && duration) { | ||
/** | ||
@@ -1128,11 +1270,11 @@ * Wrap the handler in on -> off callback | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementTransitionDelay(element) { | ||
const computedStyle = getComputedStyle(element); | ||
const propertyValue = computedStyle[transitionProperty]; | ||
const delayValue = computedStyle[transitionDelay]; | ||
function getElementTransitionDelay$1(element) { | ||
const propertyValue = getElementStyle(element, transitionProperty$1); | ||
const delayValue = getElementStyle(element, transitionDelay$1); | ||
const delayScale = delayValue.includes('ms') ? 1 : 1000; | ||
const duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
const duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(delayValue) * delayScale : 0; | ||
@@ -1147,11 +1289,10 @@ | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementTransitionDuration(element) { | ||
const computedStyle = getComputedStyle(element); | ||
const propertyValue = computedStyle[transitionProperty]; | ||
const durationValue = computedStyle[transitionDuration]; | ||
function getElementTransitionDuration$1(element) { | ||
const propertyValue = getElementStyle(element, transitionProperty$1); | ||
const durationValue = getElementStyle(element, transitionDuration$1); | ||
const durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
const duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
const duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
@@ -1166,10 +1307,10 @@ | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `transitionend` callback | ||
*/ | ||
function emulateTransitionEnd(element, handler) { | ||
function emulateTransitionEnd$1(element, handler) { | ||
let called = 0; | ||
const endEvent = new Event(transitionEndEvent); | ||
const duration = getElementTransitionDuration(element); | ||
const delay = getElementTransitionDelay(element); | ||
const endEvent = new Event(transitionEndEvent$1); | ||
const duration = getElementTransitionDuration$1(element); | ||
const delay = getElementTransitionDelay$1(element); | ||
@@ -1184,7 +1325,7 @@ if (duration) { | ||
handler.apply(element, [e]); | ||
element.removeEventListener(transitionEndEvent, transitionEndWrapper); | ||
element.removeEventListener(transitionEndEvent$1, transitionEndWrapper); | ||
called = 1; | ||
} | ||
}; | ||
element.addEventListener(transitionEndEvent, transitionEndWrapper); | ||
element.addEventListener(transitionEndEvent$1, transitionEndWrapper); | ||
setTimeout(() => { | ||
@@ -1199,48 +1340,69 @@ if (!called) element.dispatchEvent(endEvent); | ||
/** | ||
* Utility to determine if an `Element` | ||
* is partially visible in viewport. | ||
* Utility to get the computed `transitionDelay` | ||
* from Element in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @return {boolean} Boolean | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function isElementInScrollRange(element) { | ||
const bcr = element.getBoundingClientRect(); | ||
const viewportHeight = window.innerHeight || document.documentElement.clientHeight; | ||
return bcr.top <= viewportHeight && bcr.bottom >= 0; // bottom && top | ||
function getElementTransitionDelay(element) { | ||
const propertyValue = getElementStyle(element, transitionProperty); | ||
const delayValue = getElementStyle(element, transitionDelay); | ||
const delayScale = delayValue.includes('ms') ? 1 : 1000; | ||
const duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat(delayValue) * delayScale : 0; | ||
return !Number.isNaN(duration) ? duration : 0; | ||
} | ||
/** | ||
* Utility to determine if an `Element` | ||
* is fully visible in the viewport. | ||
* Utility to get the computed `transitionDuration` | ||
* from Element in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @return {boolean} Boolean | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function isElementInViewport(element) { | ||
const bcr = element.getBoundingClientRect(); | ||
return ( | ||
bcr.top >= 0 | ||
&& bcr.left >= 0 | ||
&& bcr.bottom <= (window.innerHeight || document.documentElement.clientHeight) | ||
&& bcr.right <= (window.innerWidth || document.documentElement.clientWidth) | ||
); | ||
function getElementTransitionDuration(element) { | ||
const propertyValue = getElementStyle(element, transitionProperty); | ||
const durationValue = getElementStyle(element, transitionDuration); | ||
const durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
const duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
return !Number.isNaN(duration) ? duration : 0; | ||
} | ||
/** | ||
* Checks if an element is an `<svg>`, `<img>` or `<video>`. | ||
* *Tooltip* / *Popover* works different with media elements. | ||
* @param {any} element the target element | ||
* @returns {boolean} the query result | ||
* Utility to make sure callbacks are consistently | ||
* called when transition ends. | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `transitionend` callback | ||
*/ | ||
function isMedia(element) { | ||
return [SVGElement, HTMLImageElement, HTMLVideoElement] | ||
.some((mediaType) => element instanceof mediaType); | ||
function emulateTransitionEnd(element, handler) { | ||
let called = 0; | ||
const endEvent = new Event(transitionEndEvent); | ||
const duration = getElementTransitionDuration(element); | ||
const delay = getElementTransitionDelay(element); | ||
if (supportTransition && duration) { | ||
/** | ||
* Wrap the handler in on -> off callback | ||
* @param {Event} e Event object | ||
*/ | ||
const transitionEndWrapper = (e) => { | ||
if (e.target === element) { | ||
handler.apply(element, [e]); | ||
element.removeEventListener(transitionEndEvent, transitionEndWrapper); | ||
called = 1; | ||
} | ||
}; | ||
element.addEventListener(transitionEndEvent, transitionEndWrapper); | ||
setTimeout(() => { | ||
if (!called) element.dispatchEvent(endEvent); | ||
}, duration + delay + 17); | ||
} else { | ||
handler.apply(element, [endEvent]); | ||
} | ||
} | ||
/** | ||
* Checks if a page is Right To Left. | ||
* @returns {boolean} the query result | ||
*/ | ||
const isRTL = () => document.documentElement.dir === 'rtl'; | ||
// general event options | ||
@@ -1256,3 +1418,3 @@ | ||
* | ||
* @typedef {string | Element | Function | number | boolean | null} niceValue | ||
* @typedef {string | HTMLElement | Function | number | boolean | null} niceValue | ||
*/ | ||
@@ -1283,3 +1445,3 @@ | ||
// string / function / Element / object | ||
// string / function / HTMLElement / object | ||
return value; | ||
@@ -1298,3 +1460,3 @@ } | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {Record<string, any>} defaultOps component default options | ||
@@ -1306,5 +1468,6 @@ * @param {Record<string, any>} inputOps component instance options | ||
function normalizeOptions(element, defaultOps, inputOps, ns) { | ||
// @ts-ignore -- usually our `Element` is `HTMLElement` as well | ||
const data = { ...element.dataset }; | ||
/** @type {Record<string, any>} */ | ||
const normalOps = {}; | ||
/** @type {Record<string, any>} */ | ||
const dataOps = {}; | ||
@@ -1350,11 +1513,8 @@ | ||
/** | ||
* Utility to force re-paint of an `Element` target. | ||
* Utility to force re-paint of an `HTMLElement` target. | ||
* | ||
* @param {Element | HTMLElement} element is the target | ||
* @param {HTMLElement} element is the target | ||
* @return {number} the `Element.offsetHeight` value | ||
*/ | ||
function reflow(element) { | ||
// @ts-ignore -- our `Element` is always an `HTMLElement` | ||
return element.offsetHeight; | ||
} | ||
const reflow = (element) => element.offsetHeight; | ||
@@ -1365,3 +1525,3 @@ /** | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Array} | ||
* @returns {Array<any>} | ||
*/ | ||
@@ -1375,6 +1535,3 @@ const ArrayFrom = (arr) => Array.from(arr); | ||
*/ | ||
const Float32ArrayFrom = (arr) => { | ||
const array = Array.from(arr); | ||
return Float32Array.from(array); | ||
}; | ||
const Float32ArrayFrom = (arr) => Float32Array.from(Array.from(arr)); | ||
@@ -1386,6 +1543,3 @@ /** | ||
*/ | ||
const Float64ArrayFrom = (arr) => { | ||
const array = Array.from(arr); | ||
return Float64Array.from(array); | ||
}; | ||
const Float64ArrayFrom = (arr) => Float64Array.from(Array.from(arr)); | ||
@@ -1407,24 +1561,4 @@ /** | ||
/** | ||
* Shortcut for `window.getComputedStyle(element).propertyName` | ||
* static method. | ||
* * If `element` parameter is not an `Element`, `getComputedStyle` | ||
* throws a `ReferenceError`. | ||
* * If no property is defined, the entire `CSSStyleDeclaration` | ||
* instance is returned. | ||
* | ||
* @param {Element} element target | ||
* @param {string=} property the css property | ||
* @return {string} the css property value | ||
*/ | ||
function getElementStyle(element, property) { | ||
const computedStyle = getComputedStyle(element); | ||
return property && property in computedStyle | ||
? computedStyle[property] | ||
: computedStyle; | ||
} | ||
/** | ||
* Shortcut for `Element.getAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.getAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
@@ -1435,4 +1569,4 @@ */ | ||
/** | ||
* Shortcut for `Element.setAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.setAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
@@ -1444,4 +1578,4 @@ * @param {string} value attribute value | ||
/** | ||
* Shortcut for `Element.removeAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.removeAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
@@ -1452,2 +1586,63 @@ */ | ||
/** | ||
* Shortcut for `HTMLElement.style.propertyName` method. | ||
* @param {HTMLElement} element target element | ||
* @param {Record<string, string>} styles attribute value | ||
*/ | ||
const setElementStyle = (element, styles) => ObjectAssign(element.style, styles); | ||
/** | ||
* Utility to determine if an `HTMLElement` | ||
* is partially visible in viewport. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
*/ | ||
function isElementInScrollRange(element) { | ||
const bcr = element.getBoundingClientRect(); | ||
const viewportHeight = window.innerHeight || document.documentElement.clientHeight; | ||
return bcr.top <= viewportHeight && bcr.bottom >= 0; // bottom && top | ||
} | ||
/** | ||
* Utility to determine if an `HTMLElement` | ||
* is fully visible in the viewport. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
*/ | ||
function isElementInViewport(element) { | ||
const bcr = element.getBoundingClientRect(); | ||
return ( | ||
bcr.top >= 0 | ||
&& bcr.left >= 0 | ||
&& bcr.bottom <= (window.innerHeight || document.documentElement.clientHeight) | ||
&& bcr.right <= (window.innerWidth || document.documentElement.clientWidth) | ||
); | ||
} | ||
/** | ||
* Checks if an element is an `<svg>`, `<img>` or `<video>`. | ||
* *Tooltip* / *Popover* works different with media elements. | ||
* @param {any} element the target element | ||
* @returns {boolean} the query result | ||
*/ | ||
const isMedia = (element) => typeof element === 'object' | ||
&& [SVGElement, HTMLImageElement, HTMLVideoElement] | ||
.some((mediaType) => element instanceof mediaType); | ||
/** | ||
* Checks if a page is Right To Left. | ||
* @returns {boolean} the query result | ||
*/ | ||
const isRTL = () => document.documentElement.dir === 'rtl'; | ||
/** | ||
* Shortcut for `typeof` static method. | ||
* | ||
* @param {any} str array-like iterable object | ||
* @returns {boolean} the query result | ||
*/ | ||
const isString = (str) => str && typeof str === 'string'; | ||
/** | ||
* Shortcut for `Array.isArray()` static method. | ||
@@ -1461,3 +1656,3 @@ * | ||
/** | ||
* Checks if an element is an `HTMLElement`. | ||
* Checks if an object is an `Element`. | ||
* | ||
@@ -1467,5 +1662,3 @@ * @param {any} element the target object | ||
*/ | ||
function isHTMLElement(element) { | ||
return element instanceof HTMLElement; | ||
} | ||
const isElement = (element) => element && element instanceof Element; | ||
@@ -1478,5 +1671,3 @@ /** | ||
*/ | ||
function isHTMLCollection(object) { | ||
return object instanceof HTMLCollection; | ||
} | ||
const isHTMLCollection = (object) => object instanceof HTMLCollection; | ||
@@ -1489,5 +1680,3 @@ /** | ||
*/ | ||
function isNodeList(object) { | ||
return object instanceof NodeList; | ||
} | ||
const isNodeList = (object) => object instanceof NodeList; | ||
@@ -1500,8 +1689,7 @@ /** | ||
*/ | ||
function isElementsArray(object) { | ||
return Array.isArray(object) && object.every((el) => isElement(el)); | ||
} | ||
const isElementsArray = (object) => Array.isArray(object) | ||
&& object.every((el) => isHTMLElement(el)); | ||
/** | ||
* Utility to check if target is typeof `Element` | ||
* Utility to check if target is typeof `HTMLElement` | ||
* or find one that matches a selector. | ||
@@ -1511,5 +1699,5 @@ * | ||
* | ||
* @param {Element | string} selector the input selector or target element | ||
* @param {Element=} parent optional Element to look into | ||
* @return {Element?} the Element or `querySelector` result | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {(ParentNode | HTMLElement)=} parent optional `HTMLElement` to look into | ||
* @return {HTMLElement?} the Element or `querySelector` result | ||
*/ | ||
@@ -1524,7 +1712,7 @@ function queryElement(selector, parent) { | ||
* @param {string} selector the input selector | ||
* @param {ParentNode=} parent optional Element to look into | ||
* @return {NodeList} the query result | ||
* @param {(HTMLElement | ParentNode)=} parent optional Element to look into | ||
* @return {NodeListOf<HTMLElement>} the query result | ||
*/ | ||
function querySelectorAll(selector, parent) { | ||
const lookUp = parent && isElement(parent) ? parent : document; | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return lookUp.querySelectorAll(selector); | ||
@@ -1534,10 +1722,10 @@ } | ||
/** | ||
* Shortcut for `Element.getElementsByTagName` method. | ||
* Shortcut for `HTMLElement.getElementsByTagName` method. | ||
* | ||
* @param {string} selector the tag name | ||
* @param {Element=} parent optional Element to look into | ||
* @return {HTMLCollection} the 'HTMLCollection' | ||
* @param {HTMLElement=} parent optional Element to look into | ||
* @return {HTMLCollectionOf<Element | HTMLElement>} the 'HTMLCollection' | ||
*/ | ||
function getElementsByTagName(selector, parent) { | ||
const lookUp = parent && isElement(parent) ? parent : document; | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return lookUp.getElementsByTagName(selector); | ||
@@ -1547,14 +1735,14 @@ } | ||
/** | ||
* Shortcut for `Element.getElementsByClassName` method. | ||
* Shortcut for `HTMLElement.getElementsByClassName` method. | ||
* | ||
* @param {string} selector the class name | ||
* @param {Element=} parent optional Element to look into | ||
* @return {HTMLCollection} the 'HTMLCollection' | ||
* @param {(HTMLElement)=} parent optional Element to look into | ||
* @return {HTMLCollectionOf<HTMLElement | Element>} the 'HTMLCollection' | ||
*/ | ||
function getElementsByClassName(selector, parent) { | ||
const lookUp = parent && isElement(parent) ? parent : document; | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return lookUp.getElementsByClassName(selector); | ||
} | ||
var version = "0.2.23"; | ||
var version = "0.2.24"; | ||
@@ -1634,10 +1822,18 @@ // @ts-ignore | ||
bezierEasings, | ||
animationDuration, | ||
animationDelay, | ||
animationName, | ||
animationEndEvent, | ||
transitionDuration, | ||
transitionDelay, | ||
transitionEndEvent, | ||
transitionProperty, | ||
animationDuration: animationDuration$1, | ||
animationDurationLegacy: animationDuration, | ||
animationDelay: animationDelay$1, | ||
animationDelayLegacy: animationDelay, | ||
animationName: animationName$1, | ||
animationNameLegacy: animationName, | ||
animationEndEvent: animationEndEvent$1, | ||
animationEndEventLegacy: animationEndEvent, | ||
transitionDuration: transitionDuration$1, | ||
transitionDurationLegacy: transitionDuration, | ||
transitionDelay: transitionDelay$1, | ||
transitionDelayLegacy: transitionDelay, | ||
transitionEndEvent: transitionEndEvent$1, | ||
transitionEndEventLegacy: transitionEndEvent, | ||
transitionProperty: transitionProperty$1, | ||
transitionPropertyLegacy: transitionProperty, | ||
isMobile, | ||
@@ -1679,2 +1875,3 @@ isApple, | ||
scrollWidth, | ||
userAgentData, | ||
addClass, | ||
@@ -1689,12 +1886,19 @@ removeClass, | ||
getInstance, | ||
emulateAnimationEnd, | ||
emulateTransitionEnd, | ||
emulateAnimationEnd: emulateAnimationEnd$1, | ||
emulateAnimationEndLegacy: emulateAnimationEnd, | ||
emulateTransitionEnd: emulateTransitionEnd$1, | ||
emulateTransitionEndLegacy: emulateTransitionEnd, | ||
isElementInScrollRange, | ||
isElementInViewport, | ||
passiveHandler, | ||
getElementAnimationDuration, | ||
getElementAnimationDelay, | ||
getElementTransitionDuration, | ||
getElementTransitionDelay, | ||
getElementAnimationDuration: getElementAnimationDuration$1, | ||
getElementAnimationDurationLegacy: getElementAnimationDuration, | ||
getElementAnimationDelay: getElementAnimationDelay$1, | ||
getElementAnimationDelayLegacy: getElementAnimationDelay, | ||
getElementTransitionDuration: getElementTransitionDuration$1, | ||
getElementTransitionDurationLegacy: getElementTransitionDuration, | ||
getElementTransitionDelay: getElementTransitionDelay$1, | ||
getElementTransitionDelayLegacy: getElementTransitionDelay, | ||
isArray, | ||
isString, | ||
isElement, | ||
@@ -1723,2 +1927,3 @@ isHTMLElement, | ||
getElementStyle, | ||
setElementStyle, | ||
getAttribute, | ||
@@ -1730,2 +1935,2 @@ setAttribute, | ||
export default SHORTER; | ||
export { SHORTER as default }; |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.2.23 | dnp_theme © 2021 | 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",r="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",u="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",c=/iPhone|iPad|iPod|Android/i;let l=!1;l=navigator.userAgentData?navigator.userAgentData.brands.some(e=>c.test(e.brand)):c.test(navigator.userAgent);const m=l,{userAgentData:d}=navigator,v=/(iPhone|iPod|iPad)/,b=d?d.brands.some(e=>v.test(e.brand)):v.test(navigator.userAgent),g="webkitPerspective"in document.head.style||"perspective"in document.head.style,p=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,t)}),t)}catch(e){throw Error("Passive events are not supported")}return e})(),E="webkitTransform"in document.head.style||"transform"in document.head.style,y="ontouchstart"in window||"msMaxTouchPoints"in navigator,h="webkitAnimation"in document.head.style||"animation"in document.head.style,f="webkitTransition"in document.head.style||"transition"in document.head.style;function w(e,t,n,o){const i=o||!1;e.addEventListener(t,n,i)}function k(e,t,n,o){const i=o||!1;e.removeEventListener(t,n,i)}function A(e){return e instanceof Element}function L(e,t){const n=t&&A(t)?t:document;return A(e)?e:n.querySelector(e)}const T=new Map,C={set:(e,t,n,o)=>{const i=L(e);if(A(i))if("string"==typeof o&&o.length){T.has(i)||T.set(i,new Map);T.get(i).set(o,setTimeout(t,n))}else T.set(i,setTimeout(t,n))},get:(e,t)=>{const n=L(e);if(!A(n))return null;if("string"==typeof t&&t.length){T.has(n)||T.set(n,new Map);const e=T.get(n);if(e.has(t))return e.get(t)}else if(T.has(n))return T.get(n);return null},clear:(e,t)=>{const n=L(e);if(A(n)&&T.has(n))if("string"==typeof t&&t.length){const e=T.get(n);e&&e.has(t)&&(clearTimeout(e.get(t)),e.delete(t))}else T.has(n)&&(clearTimeout(T.get(n)),T.delete(n))}},D=new Map,M={set:(e,t,n)=>{const o=L(e);if(!A(o))return;D.has(t)||D.set(t,new Map);D.get(t).set(o,n)},getAllFor:e=>D.has(e)?D.get(e):null,get:(e,t)=>{const n=L(e),o=M.getAllFor(t);return o&&A(n)&&o.has(n)?o.get(n):null},remove:(e,t)=>{if(!D.has(t))return;const n=D.get(t);n.delete(e),0===n.size&&D.delete(t)}};function O(e){const t=getComputedStyle(e),i=t[o],r=t[n],a=r.includes("ms")?1:1e3,s=h&&i&&"none"!==i?parseFloat(r)*a:0;return Number.isNaN(s)?0:s}function S(e){const n=getComputedStyle(e),i=n[o],r=n[t],a=r.includes("ms")?1:1e3,s=h&&i&&"none"!==i?parseFloat(r)*a:0;return Number.isNaN(s)?0:s}function z(e){const t=getComputedStyle(e),n=t[u],o=t[a],i=o.includes("ms")?1:1e3,r=f&&n&&"none"!==n?parseFloat(o)*i:0;return Number.isNaN(r)?0:r}function I(e){const t=getComputedStyle(e),n=t[u],o=t[r],i=o.includes("ms")?1:1e3,a=f&&n&&"none"!==n?parseFloat(o)*i:0;return Number.isNaN(a)?0:a}function N(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const P=e=>Object.keys(e);const H={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:t,animationDelay:n,animationName:o,animationEndEvent:i,transitionDuration:r,transitionDelay:a,transitionEndEvent:s,transitionProperty:u,isMobile:m,isApple:b,support3DTransform:g,supportPassive:p,supportTransform:E,supportTouch:y,supportAnimation:h,supportTransition:f,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",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:w,off:k,one:function(e,t,n,o){w(e,t,(function i(r){r.target===e&&(n.apply(e,[r]),k(e,t,i,o))}),o)},Data:M,Timer:C,getInstance:(e,t)=>M.get(e,t),emulateAnimationEnd:function(e,t){let n=0;const o=new Event(i),r=S(e),a=O(e);if(r){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)},r+a+17)}else t.apply(e,[o])},emulateTransitionEnd:function(e,t){let n=0;const o=new Event(s),i=I(e),r=z(e);if(i){const a=o=>{o.target===e&&(t.apply(e,[o]),e.removeEventListener(s,a),n=1)};e.addEventListener(s,a),setTimeout(()=>{n||e.dispatchEvent(o)},i+r+17)}else t.apply(e,[o])},isElementInScrollRange:function(e){const t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!p&&{passive:!0},getElementAnimationDuration:S,getElementAnimationDelay:O,getElementTransitionDuration:I,getElementTransitionDelay:z,isArray:e=>Array.isArray(e),isElement:A,isHTMLElement:function(e){return e instanceof HTMLElement},isNodeList:function(e){return e instanceof NodeList},isHTMLCollection:function(e){return e instanceof HTMLCollection},isElementsArray:function(e){return Array.isArray(e)&&e.every(e=>A(e))},isMedia:function(e){return[SVGElement,HTMLImageElement,HTMLVideoElement].some(t=>e instanceof t)},isRTL:()=>"rtl"===document.documentElement.dir,queryElement:function(e,t){return L(e,t)},querySelector:L,querySelectorAll:function(e,t){return(t&&A(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&A(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&A(t)?t:document).getElementsByTagName(e)},normalizeValue:N,normalizeOptions:function(e,t,n,o){const i={...e.dataset},r={},a={};return P(i).forEach(e=>{const t=o&&e.includes(o)?e.replace(o,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;a[t]=N(i[e])}),P(n).forEach(e=>{n[e]=N(n[e])}),P(t).forEach(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},ArrayFrom:e=>Array.from(e),Float32ArrayFrom:e=>{const t=Array.from(e);return Float32Array.from(t)},Float64ArrayFrom:e=>{const t=Array.from(e);return Float64Array.from(t)},ObjectAssign:(e,t)=>Object.assign(e,t),ObjectKeys:P,ObjectValues:e=>Object.values(e),getElementStyle:function(e,t){const n=getComputedStyle(e);return t&&t in n?n[t]:n},getAttribute:(e,t)=>e.getAttribute(t),setAttribute:(e,t,n)=>e.setAttribute(t,n),removeAttribute:(e,t)=>e.removeAttribute(t),Version:"0.2.23"};export default H; | ||
// shorter-js v0.2.24 | 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",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="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",u=/iPhone|iPad|iPod|Android/i;let l=!1;l=navigator.userAgentData?navigator.userAgentData.brands.some(e=>u.test(e.brand)):u.test(navigator.userAgent);const m=l,d=navigator.userAgentData,g=/(iPhone|iPod|iPad)/,v=d?d.brands.some(e=>g.test(e.brand)):g.test(navigator.userAgent),E="webkitPerspective"in document.head.style||"perspective"in document.head.style;function p(e,t,n,i){const o=i||!1;e.addEventListener(t,n,o)}function y(e,t,n,i){const o=i||!1;e.removeEventListener(t,n,o)}function b(e,t,n,i){p(e,t,(function o(a){a.target===e&&(n.apply(e,[a]),y(e,t,o,i))}),i)}const h=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});b(document,"DOMContentLoaded",()=>{},t)}catch(e){throw Error("Passive events are not supported")}return e})(),f="webkitTransform"in document.head.style||"transform"in document.head.style,w="ontouchstart"in window||"msMaxTouchPoints"in navigator,k="webkitAnimation"in document.head.style||"animation"in document.head.style,A="webkitTransition"in document.head.style||"transition"in document.head.style;const L=e=>"object"==typeof e&&e instanceof HTMLElement;function D(e,t){const n=t&&L(t)?t:document;return"object"==typeof e?e:n.querySelector(e)}const T=new Map,N={set:(e,t,n,i)=>{const o=D(e);if(L(o))if(i&&i.length){T.has(o)||T.set(o,new Map);T.get(o).set(i,setTimeout(t,n))}else T.set(o,setTimeout(t,n))},get:(e,t)=>{const n=D(e);if(!L(n))return null;if(t&&t.length){T.has(n)||T.set(n,new Map);const e=T.get(n);if(e.has(t))return e.get(t)}else if(T.has(n))return T.get(n);return null},clear:(e,t)=>{const n=D(e);if(L(n)&&T.has(n))if(t&&t.length){const e=T.get(n);e&&e.has(t)&&(clearTimeout(e.get(t)),e.delete(t))}else T.has(n)&&(clearTimeout(T.get(n)),T.delete(n))}},C=new Map,z={set:(e,t,n)=>{const i=D(e);if(!L(i))return;C.has(t)||C.set(t,new Map);C.get(t).set(i,n)},getAllFor:e=>C.has(e)?C.get(e):null,get:(e,t)=>{const n=D(e),i=z.getAllFor(t);return i&&L(n)&&i.has(n)?i.get(n):null},remove:(e,t)=>{const n=D(e);if(!C.has(t)||!n)return;const i=C.get(t);i.delete(n),0===i.size&&C.delete(t)}};function M(e,t){const n=getComputedStyle(e);return t&&t in n?n.getPropertyValue(t):""}function O(e){const t=M(e,"animationName"),n=M(e,"animationDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function S(e){const t=M(e,"animationName"),n=M(e,"animationDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function I(e){const t=M(e,i),o=M(e,n),a=o.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(o)*a:0;return Number.isNaN(r)?0:r}function P(e){const n=M(e,i),o=M(e,t),a=o.includes("ms")?1:1e3,r=k&&n&&"none"!==n?parseFloat(o)*a:0;return Number.isNaN(r)?0:r}function H(e){const t=M(e,"transitionProperty"),n=M(e,"transitionDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function F(e){const t=M(e,"transitionProperty"),n=M(e,"transitionDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function B(e){const t=M(e,c),n=M(e,r),i=n.includes("ms")?1:1e3,o=A&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function x(e){const t=M(e,c),n=M(e,a),i=n.includes("ms")?1:1e3,o=A&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function j(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const Q=e=>Object.keys(e);const R=(e,t)=>Object.assign(e,t);const V={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:a,transitionDelay:"transitionDelay",transitionDelayLegacy:r,transitionEndEvent:"transitionend",transitionEndEventLegacy:s,transitionProperty:"transitionProperty",transitionPropertyLegacy:c,isMobile:m,isApple:v,support3DTransform:E,supportPassive:h,supportTransform:f,supportTouch:w,supportAnimation:k,supportTransition:A,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:"userAgentData",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:p,off:y,one:b,Data:z,Timer:N,getInstance:(e,t)=>z.get(e,t),emulateAnimationEnd:function(e,t){let n=0;const i=new Event("animationend"),o=S(e),a=O(e);if(o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",r),n=1)};e.addEventListener("animationend",r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){let n=0;const i=new Event(o),a=P(e),r=I(e);if(k&&a){const s=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener(o,s),n=1)};e.addEventListener(o,s),setTimeout(()=>{n||e.dispatchEvent(i)},a+r+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){let n=0;const i=new Event("transitionend"),o=F(e),a=H(e);if(o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",r),n=1)};e.addEventListener("transitionend",r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){let n=0;const i=new Event(s),o=x(e),a=B(e);if(A&&o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener(s,r),n=1)};e.addEventListener(s,r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){const t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!h&&{passive:!0},getElementAnimationDuration:S,getElementAnimationDurationLegacy:P,getElementAnimationDelay:O,getElementAnimationDelayLegacy:I,getElementTransitionDuration:F,getElementTransitionDurationLegacy:x,getElementTransitionDelay:H,getElementTransitionDelayLegacy:B,isArray:e=>Array.isArray(e),isString:e=>e&&"string"==typeof e,isElement:e=>e&&e instanceof Element,isHTMLElement:L,isNodeList:e=>e instanceof NodeList,isHTMLCollection:e=>e instanceof HTMLCollection,isElementsArray:e=>Array.isArray(e)&&e.every(e=>L(e)),isMedia:e=>"object"==typeof e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(t=>e instanceof t),isRTL:()=>"rtl"===document.documentElement.dir,queryElement:function(e,t){return D(e,t)},querySelector:D,querySelectorAll:function(e,t){return(t&&L(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&L(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&L(t)?t:document).getElementsByTagName(e)},normalizeValue:j,normalizeOptions:function(e,t,n,i){const o={...e.dataset},a={},r={};return Q(o).forEach(e=>{const t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;r[t]=j(o[e])}),Q(n).forEach(e=>{n[e]=j(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,ArrayFrom:e=>Array.from(e),Float32ArrayFrom:e=>Float32Array.from(Array.from(e)),Float64ArrayFrom:e=>Float64Array.from(Array.from(e)),ObjectAssign:R,ObjectKeys:Q,ObjectValues:e=>Object.values(e),getElementStyle:M,setElementStyle:(e,t)=>R(e.style,t),getAttribute:(e,t)=>e.getAttribute(t),setAttribute:(e,t,n)=>e.setAttribute(t,n),removeAttribute:(e,t)=>e.removeAttribute(t),Version:"0.2.24"};export{V as default}; |
/*! | ||
* shorter-js v0.2.23 (https://github.com/thednp/shorter-js) | ||
* Copyright 2019-2021 © dnp_theme | ||
* shorter-js v0.2.24 (https://github.com/thednp/shorter-js) | ||
* Copyright 2019-2022 © dnp_theme | ||
* Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
@@ -9,4 +9,4 @@ */ | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global = global || self, global.SHORTER = factory()); | ||
}(this, (function () { 'use strict'; | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.SHORTER = factory()); | ||
})(this, (function () { 'use strict'; | ||
@@ -585,2 +585,8 @@ /** | ||
*/ | ||
var animationDuration$1 = 'animationDuration'; | ||
/** | ||
* A global namespace for 'animationDuration' string. | ||
* @type {string} | ||
*/ | ||
var animationDuration = 'webkitAnimation' in document.head.style ? 'webkitAnimationDuration' : 'animationDuration'; | ||
@@ -592,2 +598,8 @@ | ||
*/ | ||
var animationDelay$1 = 'animationDelay'; | ||
/** | ||
* A global namespace for 'animationDelay' string. | ||
* @type {string} | ||
*/ | ||
var animationDelay = 'webkitAnimation' in document.head.style ? 'webkitAnimationDelay' : 'animationDelay'; | ||
@@ -599,2 +611,8 @@ | ||
*/ | ||
var animationName$1 = 'animationName'; | ||
/** | ||
* A global namespace for 'animationName' string. | ||
* @type {string} | ||
*/ | ||
var animationName = 'webkitAnimation' in document.head.style ? 'webkitAnimationName' : 'animationName'; | ||
@@ -606,2 +624,8 @@ | ||
*/ | ||
var animationEndEvent$1 = 'animationend'; | ||
/** | ||
* A global namespace for 'animationend' string. | ||
* @type {string} | ||
*/ | ||
var animationEndEvent = 'webkitAnimation' in document.head.style ? 'webkitAnimationEnd' : 'animationend'; | ||
@@ -613,2 +637,8 @@ | ||
*/ | ||
var transitionDuration$1 = 'transitionDuration'; | ||
/** | ||
* A global namespace for 'transitionDuration' string. | ||
* @type {string} | ||
*/ | ||
var transitionDuration = 'webkitTransition' in document.head.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
@@ -620,2 +650,8 @@ | ||
*/ | ||
var transitionDelay$1 = 'transitionDelay'; | ||
/** | ||
* A global namespace for 'transitionDelay' string. | ||
* @type {string} | ||
*/ | ||
var transitionDelay = 'webkitTransition' in document.head.style ? 'webkitTransitionDelay' : 'transitionDelay'; | ||
@@ -627,2 +663,8 @@ | ||
*/ | ||
var transitionEndEvent$1 = 'transitionend'; | ||
/** | ||
* A global namespace for 'transitionend' string. | ||
* @type {string} | ||
*/ | ||
var transitionEndEvent = 'webkitTransition' in document.head.style ? 'webkitTransitionEnd' : 'transitionend'; | ||
@@ -634,2 +676,8 @@ | ||
*/ | ||
var transitionProperty$1 = 'transitionProperty'; | ||
/** | ||
* A global namespace for 'transitionProperty' string. | ||
* @type {string} | ||
*/ | ||
var transitionProperty = 'webkitTransition' in document.head.style ? 'webkitTransitionProperty' : 'transitionProperty'; | ||
@@ -706,9 +754,15 @@ | ||
/** | ||
* A global namespace for `userAgentData` event. | ||
* @type {string} | ||
*/ | ||
var userAgentData = 'userAgentData'; | ||
var mobileBrands = /iPhone|iPad|iPod|Android/i; | ||
var userAgentStr = 'userAgentData'; | ||
var isMobileCheck = false; | ||
if (navigator[userAgentStr]) { | ||
isMobileCheck = navigator[userAgentStr].brands.some(function (x) { return mobileBrands.test(x.brand); }); | ||
// @ts-ignore | ||
if (navigator[userAgentData]) { | ||
// @ts-ignore | ||
isMobileCheck = navigator[userAgentData].brands.some(function (x) { return mobileBrands.test(x.brand); }); | ||
} else { | ||
@@ -724,15 +778,16 @@ isMobileCheck = mobileBrands.test(navigator.userAgent); | ||
/** @type {Record<string, any>} */ | ||
// @ts-ignore | ||
var userAgentData = navigator.userAgentData; | ||
var agentData = navigator[userAgentData]; | ||
var appleBrands = /(iPhone|iPod|iPad)/; | ||
/** | ||
* A global namespace for Apple browsers. | ||
* A global boolean for Apple browsers. | ||
* @type {boolean} | ||
*/ | ||
var isApple = !userAgentData ? appleBrands.test(navigator.userAgent) | ||
: userAgentData.brands.some(function (x) { return appleBrands.test(x.brand); }); | ||
var isApple = !agentData ? appleBrands.test(navigator.userAgent) | ||
: agentData.brands.some(function (/** @type {Record<string, any>} */x) { return appleBrands.test(x.brand); }); | ||
/** | ||
* A global namespace for CSS3 3D transform support. | ||
* A global `boolean` for CSS3 3D transform support. | ||
* @type {boolean} | ||
@@ -743,2 +798,51 @@ */ | ||
/** | ||
* Add eventListener to an `HTMLElement` | `Document` target. | ||
* | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
function on(element, eventName, handler, options) { | ||
var ops = options || false; | ||
element.addEventListener(eventName, handler, ops); | ||
} | ||
/** | ||
* Remove eventListener from an `HTMLElement` | `Document` target. | ||
* | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
function off(element, eventName, handler, options) { | ||
var ops = options || false; | ||
element.removeEventListener(eventName, handler, ops); | ||
} | ||
/** | ||
* Add an `eventListener` to an `HTMLElement` | `Document` target | ||
* and remove it once callback is called. | ||
* | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
function one(element, eventName, handler, options) { | ||
/** | ||
* Wrap the handler for easy on -> off | ||
* @param {Event} e the Event object | ||
*/ | ||
function handlerWrapper(e) { | ||
if (e.target === element) { | ||
handler.apply(element, [e]); | ||
off(element, eventName, handlerWrapper, options); | ||
} | ||
} | ||
on(element, eventName, handlerWrapper, options); | ||
} | ||
/** | ||
* A global namespace for passive events support. | ||
@@ -756,5 +860,3 @@ * @type {boolean} | ||
}); | ||
document[addEventListener]('DOMContentLoaded', function wrap() { | ||
document[removeEventListener]('DOMContentLoaded', wrap, opts); | ||
}, opts); | ||
one(document, DOMContentLoadedEvent, function () {}, opts); | ||
} catch (e) { | ||
@@ -780,3 +882,3 @@ throw Error('Passive events are not supported'); | ||
/** | ||
* A global namespace for CSS3 animation support. | ||
* A global `boolean` for CSS3 animation support. | ||
* @type {boolean} | ||
@@ -824,80 +926,31 @@ */ | ||
/** | ||
* Add eventListener to Element | ||
* Checks if an element is an `HTMLElement`. | ||
* | ||
* @param {Element} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
*/ | ||
function on(element, eventName, handler, options) { | ||
var ops = options || false; | ||
element.addEventListener(eventName, handler, ops); | ||
} | ||
/** | ||
* Remove eventListener from Element | ||
* | ||
* @param {Element} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
*/ | ||
function off(element, eventName, handler, options) { | ||
var ops = options || false; | ||
element.removeEventListener(eventName, handler, ops); | ||
} | ||
/** | ||
* Add an eventListener to Element | ||
* and remove it once callback is called. | ||
* | ||
* @param {Element} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
*/ | ||
function one(element, eventName, handler, options) { | ||
/** | ||
* Wrap the handler for easy on -> off | ||
* @param {Event} e the Event object | ||
*/ | ||
function handlerWrapper(e) { | ||
if (e.target === element) { | ||
handler.apply(element, [e]); | ||
off(element, eventName, handlerWrapper, options); | ||
} | ||
} | ||
on(element, eventName, handlerWrapper, options); | ||
} | ||
/** | ||
* Checks if an object is an `Element`. | ||
* | ||
* @param {any} element the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
function isElement(element) { | ||
return element instanceof Element; | ||
} | ||
var isHTMLElement = function (element) { return typeof element === 'object' && element instanceof HTMLElement; }; | ||
/** | ||
* Utility to check if target is typeof `Element` | ||
* Utility to check if target is typeof `HTMLElement` | ||
* or find one that matches a selector. | ||
* | ||
* @param {Element | string} selector the input selector or target element | ||
* @param {Element=} parent optional Element to look into | ||
* @return {Element?} the Element or `querySelector` result | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {(ParentNode | HTMLElement)=} parent optional `HTMLElement` to look into | ||
* @return {HTMLElement?} the `HTMLElement` or `querySelector` result | ||
*/ | ||
function querySelector(selector, parent) { | ||
var lookUp = parent && isElement(parent) ? parent : document; | ||
// @ts-ignore -- `isElement` is just as good | ||
return isElement(selector) ? selector : lookUp.querySelector(selector); | ||
var lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return typeof selector === 'object' ? selector : lookUp.querySelector(selector); | ||
} | ||
var TimeCache = new Map(); | ||
/** | ||
* An interface for one or more `TimerHandler`s per `Element`. | ||
* @see https://github.com/thednp/navbar.js/ | ||
*/ | ||
var Timer = { | ||
/** | ||
* Sets a new timeout timer for an element, or element -> key association. | ||
* @param {Element | string} target target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {ReturnType<TimerHandler>} callback the callback | ||
@@ -909,5 +962,6 @@ * @param {number} delay the execution delay | ||
var element = querySelector(target); | ||
if (!isElement(element)) { return; } | ||
if (typeof key === 'string' && key.length) { | ||
if (!isHTMLElement(element)) { return; } | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
@@ -925,3 +979,3 @@ TimeCache.set(element, new Map()); | ||
* Returns the timer associated with the target. | ||
* @param {Element | string} target target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string=} key a unique | ||
@@ -932,5 +986,6 @@ * @returns {Map<Element, TimerHandler>?} the timer | ||
var element = querySelector(target); | ||
if (!isElement(element)) { return null; } | ||
if (typeof key === 'string' && key.length) { | ||
if (!isHTMLElement(element)) { return null; } | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
@@ -951,3 +1006,3 @@ TimeCache.set(element, new Map()); | ||
* Clears the element's timer. | ||
* @param {Element} target target element | ||
* @param {HTMLElement} target target element | ||
* @param {string=} key a unique | ||
@@ -958,5 +1013,5 @@ */ | ||
if (!isElement(element) || !TimeCache.has(element)) { return; } | ||
if (!isHTMLElement(element) || !TimeCache.has(element)) { return; } | ||
if (typeof key === 'string' && key.length) { | ||
if (key && key.length) { | ||
var keyTimers = TimeCache.get(element); | ||
@@ -983,9 +1038,9 @@ | ||
* Sets web components data. | ||
* @param {Element | string} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @param {any} instance the component instance | ||
*/ | ||
set: function (element, component, instance) { | ||
var ELEMENT = querySelector(element); | ||
if (!isElement(ELEMENT)) { return; } | ||
set: function (target, component, instance) { | ||
var element = querySelector(target); | ||
if (!isHTMLElement(element)) { return; } | ||
@@ -997,3 +1052,3 @@ if (!componentData.has(component)) { | ||
var instanceMap = componentData.get(component); | ||
instanceMap.set(ELEMENT, instance); | ||
instanceMap.set(element, instance); | ||
}, | ||
@@ -1015,12 +1070,12 @@ | ||
* Returns the instance associated with the target. | ||
* @param {Element | string} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any?} the instance | ||
*/ | ||
get: function (element, component) { | ||
var ELEMENT = querySelector(element); | ||
get: function (target, component) { | ||
var element = querySelector(target); | ||
var allForC = Data.getAllFor(component); | ||
if (allForC && isElement(ELEMENT) && allForC.has(ELEMENT)) { | ||
return allForC.get(ELEMENT); | ||
if (allForC && isHTMLElement(element) && allForC.has(element)) { | ||
return allForC.get(element); | ||
} | ||
@@ -1032,7 +1087,8 @@ return null; | ||
* Removes web components data. | ||
* @param {Element} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
*/ | ||
remove: function (element, component) { | ||
if (!componentData.has(component)) { return; } | ||
remove: function (target, component) { | ||
var element = querySelector(target); | ||
if (!componentData.has(component) || !element) { return; } | ||
@@ -1050,19 +1106,106 @@ var instanceMap = componentData.get(component); | ||
* An alias for `Data.get()`. | ||
* @param {Element | string} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any} the request result | ||
* @returns {Record<string, any>?} the request result | ||
*/ | ||
var getInstance = function (element, component) { return Data.get(element, component); }; | ||
var getInstance = function (target, component) { return Data.get(target, component); }; | ||
/** | ||
* Shortcut for `window.getComputedStyle(element).propertyName` | ||
* static method. | ||
* | ||
* * If `element` parameter is not an `HTMLElement`, `getComputedStyle` | ||
* throws a `ReferenceError`. | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {string=} property the css property | ||
* @return {string} the css property value | ||
*/ | ||
function getElementStyle(element, property) { | ||
var computedStyle = getComputedStyle(element); | ||
return property && property in computedStyle | ||
? computedStyle.getPropertyValue(property) | ||
: ''; | ||
} | ||
/** | ||
* Utility to get the computed `animationDelay` | ||
* from Element in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementAnimationDelay$1(element) { | ||
var propertyValue = getElementStyle(element, animationName$1); | ||
var durationValue = getElementStyle(element, animationDelay$1); | ||
var durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
var duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
return !Number.isNaN(duration) ? duration : 0; | ||
} | ||
/** | ||
* Utility to get the computed `animationDuration` | ||
* from `HTMLElement` in miliseconds. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementAnimationDuration$1(element) { | ||
var propertyValue = getElementStyle(element, animationName$1); | ||
var durationValue = getElementStyle(element, animationDuration$1); | ||
var durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
var duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
return !Number.isNaN(duration) ? duration : 0; | ||
} | ||
/** | ||
* Utility to make sure callbacks are consistently | ||
* called when animation ends. | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `animationend` callback | ||
*/ | ||
function emulateAnimationEnd$1(element, handler) { | ||
var called = 0; | ||
var endEvent = new Event(animationEndEvent$1); | ||
var duration = getElementAnimationDuration$1(element); | ||
var delay = getElementAnimationDelay$1(element); | ||
if (duration) { | ||
/** | ||
* Wrap the handler in on -> off callback | ||
* @param {Event} e Event object | ||
*/ | ||
var animationEndWrapper = function (e) { | ||
if (e.target === element) { | ||
handler.apply(element, [e]); | ||
element.removeEventListener(animationEndEvent$1, animationEndWrapper); | ||
called = 1; | ||
} | ||
}; | ||
element.addEventListener(animationEndEvent$1, animationEndWrapper); | ||
setTimeout(function () { | ||
if (!called) { element.dispatchEvent(endEvent); } | ||
}, duration + delay + 17); | ||
} else { | ||
handler.apply(element, [endEvent]); | ||
} | ||
} | ||
/** | ||
* Utility to get the computed `animationDelay` | ||
* from Element in miliseconds. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementAnimationDelay(element) { | ||
var computedStyle = getComputedStyle(element); | ||
var propertyValue = computedStyle[animationName]; | ||
var durationValue = computedStyle[animationDelay]; | ||
var propertyValue = getElementStyle(element, animationName); | ||
var durationValue = getElementStyle(element, animationDelay); | ||
var durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
@@ -1077,11 +1220,10 @@ var duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
* Utility to get the computed `animationDuration` | ||
* from Element in miliseconds. | ||
* from `HTMLElement` in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementAnimationDuration(element) { | ||
var computedStyle = getComputedStyle(element); | ||
var propertyValue = computedStyle[animationName]; | ||
var durationValue = computedStyle[animationDuration]; | ||
var propertyValue = getElementStyle(element, animationName); | ||
var durationValue = getElementStyle(element, animationDuration); | ||
var durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
@@ -1098,3 +1240,3 @@ var duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `animationend` callback | ||
@@ -1108,3 +1250,3 @@ */ | ||
if (duration) { | ||
if (supportAnimation && duration) { | ||
/** | ||
@@ -1134,11 +1276,11 @@ * Wrap the handler in on -> off callback | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementTransitionDelay(element) { | ||
var computedStyle = getComputedStyle(element); | ||
var propertyValue = computedStyle[transitionProperty]; | ||
var delayValue = computedStyle[transitionDelay]; | ||
function getElementTransitionDelay$1(element) { | ||
var propertyValue = getElementStyle(element, transitionProperty$1); | ||
var delayValue = getElementStyle(element, transitionDelay$1); | ||
var delayScale = delayValue.includes('ms') ? 1 : 1000; | ||
var duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
var duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(delayValue) * delayScale : 0; | ||
@@ -1153,11 +1295,10 @@ | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function getElementTransitionDuration(element) { | ||
var computedStyle = getComputedStyle(element); | ||
var propertyValue = computedStyle[transitionProperty]; | ||
var durationValue = computedStyle[transitionDuration]; | ||
function getElementTransitionDuration$1(element) { | ||
var propertyValue = getElementStyle(element, transitionProperty$1); | ||
var durationValue = getElementStyle(element, transitionDuration$1); | ||
var durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
var duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
var duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
@@ -1172,10 +1313,10 @@ | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `transitionend` callback | ||
*/ | ||
function emulateTransitionEnd(element, handler) { | ||
function emulateTransitionEnd$1(element, handler) { | ||
var called = 0; | ||
var endEvent = new Event(transitionEndEvent); | ||
var duration = getElementTransitionDuration(element); | ||
var delay = getElementTransitionDelay(element); | ||
var endEvent = new Event(transitionEndEvent$1); | ||
var duration = getElementTransitionDuration$1(element); | ||
var delay = getElementTransitionDelay$1(element); | ||
@@ -1190,7 +1331,7 @@ if (duration) { | ||
handler.apply(element, [e]); | ||
element.removeEventListener(transitionEndEvent, transitionEndWrapper); | ||
element.removeEventListener(transitionEndEvent$1, transitionEndWrapper); | ||
called = 1; | ||
} | ||
}; | ||
element.addEventListener(transitionEndEvent, transitionEndWrapper); | ||
element.addEventListener(transitionEndEvent$1, transitionEndWrapper); | ||
setTimeout(function () { | ||
@@ -1205,48 +1346,69 @@ if (!called) { element.dispatchEvent(endEvent); } | ||
/** | ||
* Utility to determine if an `Element` | ||
* is partially visible in viewport. | ||
* Utility to get the computed `transitionDelay` | ||
* from Element in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @return {boolean} Boolean | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function isElementInScrollRange(element) { | ||
var bcr = element.getBoundingClientRect(); | ||
var viewportHeight = window.innerHeight || document.documentElement.clientHeight; | ||
return bcr.top <= viewportHeight && bcr.bottom >= 0; // bottom && top | ||
function getElementTransitionDelay(element) { | ||
var propertyValue = getElementStyle(element, transitionProperty); | ||
var delayValue = getElementStyle(element, transitionDelay); | ||
var delayScale = delayValue.includes('ms') ? 1 : 1000; | ||
var duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat(delayValue) * delayScale : 0; | ||
return !Number.isNaN(duration) ? duration : 0; | ||
} | ||
/** | ||
* Utility to determine if an `Element` | ||
* is fully visible in the viewport. | ||
* Utility to get the computed `transitionDuration` | ||
* from Element in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @return {boolean} Boolean | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
function isElementInViewport(element) { | ||
var bcr = element.getBoundingClientRect(); | ||
return ( | ||
bcr.top >= 0 | ||
&& bcr.left >= 0 | ||
&& bcr.bottom <= (window.innerHeight || document.documentElement.clientHeight) | ||
&& bcr.right <= (window.innerWidth || document.documentElement.clientWidth) | ||
); | ||
function getElementTransitionDuration(element) { | ||
var propertyValue = getElementStyle(element, transitionProperty); | ||
var durationValue = getElementStyle(element, transitionDuration); | ||
var durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
var duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
return !Number.isNaN(duration) ? duration : 0; | ||
} | ||
/** | ||
* Checks if an element is an `<svg>`, `<img>` or `<video>`. | ||
* *Tooltip* / *Popover* works different with media elements. | ||
* @param {any} element the target element | ||
* @returns {boolean} the query result | ||
* Utility to make sure callbacks are consistently | ||
* called when transition ends. | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `transitionend` callback | ||
*/ | ||
function isMedia(element) { | ||
return [SVGElement, HTMLImageElement, HTMLVideoElement] | ||
.some(function (mediaType) { return element instanceof mediaType; }); | ||
function emulateTransitionEnd(element, handler) { | ||
var called = 0; | ||
var endEvent = new Event(transitionEndEvent); | ||
var duration = getElementTransitionDuration(element); | ||
var delay = getElementTransitionDelay(element); | ||
if (supportTransition && duration) { | ||
/** | ||
* Wrap the handler in on -> off callback | ||
* @param {Event} e Event object | ||
*/ | ||
var transitionEndWrapper = function (e) { | ||
if (e.target === element) { | ||
handler.apply(element, [e]); | ||
element.removeEventListener(transitionEndEvent, transitionEndWrapper); | ||
called = 1; | ||
} | ||
}; | ||
element.addEventListener(transitionEndEvent, transitionEndWrapper); | ||
setTimeout(function () { | ||
if (!called) { element.dispatchEvent(endEvent); } | ||
}, duration + delay + 17); | ||
} else { | ||
handler.apply(element, [endEvent]); | ||
} | ||
} | ||
/** | ||
* Checks if a page is Right To Left. | ||
* @returns {boolean} the query result | ||
*/ | ||
var isRTL = function () { return document.documentElement.dir === 'rtl'; }; | ||
// general event options | ||
@@ -1262,3 +1424,3 @@ | ||
* | ||
* @typedef {string | Element | Function | number | boolean | null} niceValue | ||
* @typedef {string | HTMLElement | Function | number | boolean | null} niceValue | ||
*/ | ||
@@ -1289,3 +1451,3 @@ | ||
// string / function / Element / object | ||
// string / function / HTMLElement / object | ||
return value; | ||
@@ -1304,3 +1466,3 @@ } | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {Record<string, any>} defaultOps component default options | ||
@@ -1312,5 +1474,6 @@ * @param {Record<string, any>} inputOps component instance options | ||
function normalizeOptions(element, defaultOps, inputOps, ns) { | ||
// @ts-ignore -- usually our `Element` is `HTMLElement` as well | ||
var data = Object.assign({}, element.dataset); | ||
/** @type {Record<string, any>} */ | ||
var normalOps = {}; | ||
/** @type {Record<string, any>} */ | ||
var dataOps = {}; | ||
@@ -1356,11 +1519,8 @@ | ||
/** | ||
* Utility to force re-paint of an `Element` target. | ||
* Utility to force re-paint of an `HTMLElement` target. | ||
* | ||
* @param {Element | HTMLElement} element is the target | ||
* @param {HTMLElement} element is the target | ||
* @return {number} the `Element.offsetHeight` value | ||
*/ | ||
function reflow(element) { | ||
// @ts-ignore -- our `Element` is always an `HTMLElement` | ||
return element.offsetHeight; | ||
} | ||
var reflow = function (element) { return element.offsetHeight; }; | ||
@@ -1371,3 +1531,3 @@ /** | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Array} | ||
* @returns {Array<any>} | ||
*/ | ||
@@ -1381,6 +1541,3 @@ var ArrayFrom = function (arr) { return Array.from(arr); }; | ||
*/ | ||
var Float32ArrayFrom = function (arr) { | ||
var array = Array.from(arr); | ||
return Float32Array.from(array); | ||
}; | ||
var Float32ArrayFrom = function (arr) { return Float32Array.from(Array.from(arr)); }; | ||
@@ -1392,6 +1549,3 @@ /** | ||
*/ | ||
var Float64ArrayFrom = function (arr) { | ||
var array = Array.from(arr); | ||
return Float64Array.from(array); | ||
}; | ||
var Float64ArrayFrom = function (arr) { return Float64Array.from(Array.from(arr)); }; | ||
@@ -1413,24 +1567,4 @@ /** | ||
/** | ||
* Shortcut for `window.getComputedStyle(element).propertyName` | ||
* static method. | ||
* * If `element` parameter is not an `Element`, `getComputedStyle` | ||
* throws a `ReferenceError`. | ||
* * If no property is defined, the entire `CSSStyleDeclaration` | ||
* instance is returned. | ||
* | ||
* @param {Element} element target | ||
* @param {string=} property the css property | ||
* @return {string} the css property value | ||
*/ | ||
function getElementStyle(element, property) { | ||
var computedStyle = getComputedStyle(element); | ||
return property && property in computedStyle | ||
? computedStyle[property] | ||
: computedStyle; | ||
} | ||
/** | ||
* Shortcut for `Element.getAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.getAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
@@ -1441,4 +1575,4 @@ */ | ||
/** | ||
* Shortcut for `Element.setAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.setAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
@@ -1450,4 +1584,4 @@ * @param {string} value attribute value | ||
/** | ||
* Shortcut for `Element.removeAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.removeAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
@@ -1458,2 +1592,63 @@ */ | ||
/** | ||
* Shortcut for `HTMLElement.style.propertyName` method. | ||
* @param {HTMLElement} element target element | ||
* @param {Record<string, string>} styles attribute value | ||
*/ | ||
var setElementStyle = function (element, styles) { return ObjectAssign(element.style, styles); }; | ||
/** | ||
* Utility to determine if an `HTMLElement` | ||
* is partially visible in viewport. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
*/ | ||
function isElementInScrollRange(element) { | ||
var bcr = element.getBoundingClientRect(); | ||
var viewportHeight = window.innerHeight || document.documentElement.clientHeight; | ||
return bcr.top <= viewportHeight && bcr.bottom >= 0; // bottom && top | ||
} | ||
/** | ||
* Utility to determine if an `HTMLElement` | ||
* is fully visible in the viewport. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
*/ | ||
function isElementInViewport(element) { | ||
var bcr = element.getBoundingClientRect(); | ||
return ( | ||
bcr.top >= 0 | ||
&& bcr.left >= 0 | ||
&& bcr.bottom <= (window.innerHeight || document.documentElement.clientHeight) | ||
&& bcr.right <= (window.innerWidth || document.documentElement.clientWidth) | ||
); | ||
} | ||
/** | ||
* Checks if an element is an `<svg>`, `<img>` or `<video>`. | ||
* *Tooltip* / *Popover* works different with media elements. | ||
* @param {any} element the target element | ||
* @returns {boolean} the query result | ||
*/ | ||
var isMedia = function (element) { return typeof element === 'object' | ||
&& [SVGElement, HTMLImageElement, HTMLVideoElement] | ||
.some(function (mediaType) { return element instanceof mediaType; }); }; | ||
/** | ||
* Checks if a page is Right To Left. | ||
* @returns {boolean} the query result | ||
*/ | ||
var isRTL = function () { return document.documentElement.dir === 'rtl'; }; | ||
/** | ||
* Shortcut for `typeof` static method. | ||
* | ||
* @param {any} str array-like iterable object | ||
* @returns {boolean} the query result | ||
*/ | ||
var isString = function (str) { return str && typeof str === 'string'; }; | ||
/** | ||
* Shortcut for `Array.isArray()` static method. | ||
@@ -1467,3 +1662,3 @@ * | ||
/** | ||
* Checks if an element is an `HTMLElement`. | ||
* Checks if an object is an `Element`. | ||
* | ||
@@ -1473,5 +1668,3 @@ * @param {any} element the target object | ||
*/ | ||
function isHTMLElement(element) { | ||
return element instanceof HTMLElement; | ||
} | ||
var isElement = function (element) { return element && element instanceof Element; }; | ||
@@ -1484,5 +1677,3 @@ /** | ||
*/ | ||
function isHTMLCollection(object) { | ||
return object instanceof HTMLCollection; | ||
} | ||
var isHTMLCollection = function (object) { return object instanceof HTMLCollection; }; | ||
@@ -1495,5 +1686,3 @@ /** | ||
*/ | ||
function isNodeList(object) { | ||
return object instanceof NodeList; | ||
} | ||
var isNodeList = function (object) { return object instanceof NodeList; }; | ||
@@ -1506,8 +1695,7 @@ /** | ||
*/ | ||
function isElementsArray(object) { | ||
return Array.isArray(object) && object.every(function (el) { return isElement(el); }); | ||
} | ||
var isElementsArray = function (object) { return Array.isArray(object) | ||
&& object.every(function (el) { return isHTMLElement(el); }); }; | ||
/** | ||
* Utility to check if target is typeof `Element` | ||
* Utility to check if target is typeof `HTMLElement` | ||
* or find one that matches a selector. | ||
@@ -1517,5 +1705,5 @@ * | ||
* | ||
* @param {Element | string} selector the input selector or target element | ||
* @param {Element=} parent optional Element to look into | ||
* @return {Element?} the Element or `querySelector` result | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {(ParentNode | HTMLElement)=} parent optional `HTMLElement` to look into | ||
* @return {HTMLElement?} the Element or `querySelector` result | ||
*/ | ||
@@ -1530,7 +1718,7 @@ function queryElement(selector, parent) { | ||
* @param {string} selector the input selector | ||
* @param {ParentNode=} parent optional Element to look into | ||
* @return {NodeList} the query result | ||
* @param {(HTMLElement | ParentNode)=} parent optional Element to look into | ||
* @return {NodeListOf<HTMLElement>} the query result | ||
*/ | ||
function querySelectorAll(selector, parent) { | ||
var lookUp = parent && isElement(parent) ? parent : document; | ||
var lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return lookUp.querySelectorAll(selector); | ||
@@ -1540,10 +1728,10 @@ } | ||
/** | ||
* Shortcut for `Element.getElementsByTagName` method. | ||
* Shortcut for `HTMLElement.getElementsByTagName` method. | ||
* | ||
* @param {string} selector the tag name | ||
* @param {Element=} parent optional Element to look into | ||
* @return {HTMLCollection} the 'HTMLCollection' | ||
* @param {HTMLElement=} parent optional Element to look into | ||
* @return {HTMLCollectionOf<Element | HTMLElement>} the 'HTMLCollection' | ||
*/ | ||
function getElementsByTagName(selector, parent) { | ||
var lookUp = parent && isElement(parent) ? parent : document; | ||
var lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return lookUp.getElementsByTagName(selector); | ||
@@ -1553,14 +1741,14 @@ } | ||
/** | ||
* Shortcut for `Element.getElementsByClassName` method. | ||
* Shortcut for `HTMLElement.getElementsByClassName` method. | ||
* | ||
* @param {string} selector the class name | ||
* @param {Element=} parent optional Element to look into | ||
* @return {HTMLCollection} the 'HTMLCollection' | ||
* @param {(HTMLElement)=} parent optional Element to look into | ||
* @return {HTMLCollectionOf<HTMLElement | Element>} the 'HTMLCollection' | ||
*/ | ||
function getElementsByClassName(selector, parent) { | ||
var lookUp = parent && isElement(parent) ? parent : document; | ||
var lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return lookUp.getElementsByClassName(selector); | ||
} | ||
var version = "0.2.23"; | ||
var version = "0.2.24"; | ||
@@ -1640,10 +1828,18 @@ // @ts-ignore | ||
bezierEasings: bezierEasings, | ||
animationDuration: animationDuration, | ||
animationDelay: animationDelay, | ||
animationName: animationName, | ||
animationEndEvent: animationEndEvent, | ||
transitionDuration: transitionDuration, | ||
transitionDelay: transitionDelay, | ||
transitionEndEvent: transitionEndEvent, | ||
transitionProperty: transitionProperty, | ||
animationDuration: animationDuration$1, | ||
animationDurationLegacy: animationDuration, | ||
animationDelay: animationDelay$1, | ||
animationDelayLegacy: animationDelay, | ||
animationName: animationName$1, | ||
animationNameLegacy: animationName, | ||
animationEndEvent: animationEndEvent$1, | ||
animationEndEventLegacy: animationEndEvent, | ||
transitionDuration: transitionDuration$1, | ||
transitionDurationLegacy: transitionDuration, | ||
transitionDelay: transitionDelay$1, | ||
transitionDelayLegacy: transitionDelay, | ||
transitionEndEvent: transitionEndEvent$1, | ||
transitionEndEventLegacy: transitionEndEvent, | ||
transitionProperty: transitionProperty$1, | ||
transitionPropertyLegacy: transitionProperty, | ||
isMobile: isMobile, | ||
@@ -1685,2 +1881,3 @@ isApple: isApple, | ||
scrollWidth: scrollWidth, | ||
userAgentData: userAgentData, | ||
addClass: addClass, | ||
@@ -1695,12 +1892,19 @@ removeClass: removeClass, | ||
getInstance: getInstance, | ||
emulateAnimationEnd: emulateAnimationEnd, | ||
emulateTransitionEnd: emulateTransitionEnd, | ||
emulateAnimationEnd: emulateAnimationEnd$1, | ||
emulateAnimationEndLegacy: emulateAnimationEnd, | ||
emulateTransitionEnd: emulateTransitionEnd$1, | ||
emulateTransitionEndLegacy: emulateTransitionEnd, | ||
isElementInScrollRange: isElementInScrollRange, | ||
isElementInViewport: isElementInViewport, | ||
passiveHandler: passiveHandler, | ||
getElementAnimationDuration: getElementAnimationDuration, | ||
getElementAnimationDelay: getElementAnimationDelay, | ||
getElementTransitionDuration: getElementTransitionDuration, | ||
getElementTransitionDelay: getElementTransitionDelay, | ||
getElementAnimationDuration: getElementAnimationDuration$1, | ||
getElementAnimationDurationLegacy: getElementAnimationDuration, | ||
getElementAnimationDelay: getElementAnimationDelay$1, | ||
getElementAnimationDelayLegacy: getElementAnimationDelay, | ||
getElementTransitionDuration: getElementTransitionDuration$1, | ||
getElementTransitionDurationLegacy: getElementTransitionDuration, | ||
getElementTransitionDelay: getElementTransitionDelay$1, | ||
getElementTransitionDelayLegacy: getElementTransitionDelay, | ||
isArray: isArray, | ||
isString: isString, | ||
isElement: isElement, | ||
@@ -1729,2 +1933,3 @@ isHTMLElement: isHTMLElement, | ||
getElementStyle: getElementStyle, | ||
setElementStyle: setElementStyle, | ||
getAttribute: getAttribute, | ||
@@ -1738,2 +1943,2 @@ setAttribute: setAttribute, | ||
}))); | ||
})); |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.2.23 | dnp_theme © 2021 | MIT-License | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=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",r="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="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=/iPhone|iPad|iPod|Android/i,l=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return c.test(e.brand)})):c.test(navigator.userAgent),m=navigator.userAgentData,d=/(iPhone|iPod|iPad)/,v=m?m.brands.some((function(e){return d.test(e.brand)})):d.test(navigator.userAgent),f="webkitPerspective"in document.head.style||"perspective"in document.head.style,b=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,t)}),t)}catch(e){throw Error("Passive events are not supported")}return e}(),p="webkitTransform"in document.head.style||"transform"in document.head.style,g="ontouchstart"in window||"msMaxTouchPoints"in navigator,E="webkitAnimation"in document.head.style||"animation"in document.head.style,y="webkitTransition"in document.head.style||"transition"in document.head.style;function h(e,t,n,i){var r=i||!1;e.addEventListener(t,n,r)}function w(e,t,n,i){var r=i||!1;e.removeEventListener(t,n,r)}function k(e){return e instanceof Element}function A(e,t){var n=t&&k(t)?t:document;return k(e)?e:n.querySelector(e)}var L=new Map,T={set:function(e,t,n,i){var r=A(e);k(r)&&("string"==typeof i&&i.length?(L.has(r)||L.set(r,new Map),L.get(r).set(i,setTimeout(t,n))):L.set(r,setTimeout(t,n)))},get:function(e,t){var n=A(e);if(!k(n))return null;if("string"==typeof t&&t.length){L.has(n)||L.set(n,new Map);var i=L.get(n);if(i.has(t))return i.get(t)}else if(L.has(n))return L.get(n);return null},clear:function(e,t){var n=A(e);if(k(n)&&L.has(n))if("string"==typeof t&&t.length){var i=L.get(n);i&&i.has(t)&&(clearTimeout(i.get(t)),i.delete(t))}else L.has(n)&&(clearTimeout(L.get(n)),L.delete(n))}},C=new Map,D={set:function(e,t,n){var i=A(e);k(i)&&(C.has(t)||C.set(t,new Map),C.get(t).set(i,n))},getAllFor:function(e){return C.has(e)?C.get(e):null},get:function(e,t){var n=A(e),i=D.getAllFor(t);return i&&k(n)&&i.has(n)?i.get(n):null},remove:function(e,t){if(C.has(t)){var n=C.get(t);n.delete(e),0===n.size&&C.delete(t)}}};function O(e){var t=getComputedStyle(e),r=t[i],o=t[n],a=o.includes("ms")?1:1e3,u=E&&r&&"none"!==r?parseFloat(o)*a:0;return Number.isNaN(u)?0:u}function S(e){var n=getComputedStyle(e),r=n[i],o=n[t],a=o.includes("ms")?1:1e3,u=E&&r&&"none"!==r?parseFloat(o)*a:0;return Number.isNaN(u)?0:u}function M(e){var t=getComputedStyle(e),n=t[s],i=t[a],r=i.includes("ms")?1:1e3,o=y&&n&&"none"!==n?parseFloat(i)*r:0;return Number.isNaN(o)?0:o}function z(e){var t=getComputedStyle(e),n=t[s],i=t[o],r=i.includes("ms")?1:1e3,a=y&&n&&"none"!==n?parseFloat(i)*r:0;return Number.isNaN(a)?0:a}function I(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}var N=function(e){return Object.keys(e)};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:t,animationDelay:n,animationName:i,animationEndEvent:r,transitionDuration:o,transitionDelay:a,transitionEndEvent:u,transitionProperty:s,isMobile:l,isApple:v,support3DTransform:f,supportPassive:b,supportTransform:p,supportTouch:g,supportAnimation:E,supportTransition:y,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",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:function(e,t,n,i){h(e,t,(function r(o){o.target===e&&(n.apply(e,[o]),w(e,t,r,i))}),i)},Data:D,Timer:T,getInstance:function(e,t){return D.get(e,t)},emulateAnimationEnd:function(e,t){var n=0,i=new Event(r),o=S(e),a=O(e);if(o){var u=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(r,u),n=1)};e.addEventListener(r,u),setTimeout((function(){n||e.dispatchEvent(i)}),o+a+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){var n=0,i=new Event(u),r=z(e),o=M(e);if(r){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)}),r+o+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=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!b&&{passive:!0},getElementAnimationDuration:S,getElementAnimationDelay:O,getElementTransitionDuration:z,getElementTransitionDelay:M,isArray:function(e){return Array.isArray(e)},isElement:k,isHTMLElement:function(e){return e instanceof HTMLElement},isNodeList:function(e){return e instanceof NodeList},isHTMLCollection:function(e){return e instanceof HTMLCollection},isElementsArray:function(e){return Array.isArray(e)&&e.every((function(e){return k(e)}))},isMedia:function(e){return[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(t){return e instanceof t}))},isRTL:function(){return"rtl"===document.documentElement.dir},queryElement:function(e,t){return A(e,t)},querySelector:A,querySelectorAll:function(e,t){return(t&&k(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&k(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&k(t)?t:document).getElementsByTagName(e)},normalizeValue:I,normalizeOptions:function(e,t,n,i){var r=Object.assign({},e.dataset),o={},a={};return N(r).forEach((function(e){var t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[t]=I(r[e])})),N(n).forEach((function(e){n[e]=I(n[e])})),N(t).forEach((function(e){o[e]=e in n?n[e]:e in a?a[e]:t[e]})),o},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(t+" "+e)}},reflow:function(e){return e.offsetHeight},ArrayFrom:function(e){return Array.from(e)},Float32ArrayFrom:function(e){var t=Array.from(e);return Float32Array.from(t)},Float64ArrayFrom:function(e){var t=Array.from(e);return Float64Array.from(t)},ObjectAssign:function(e,t){return Object.assign(e,t)},ObjectKeys:N,ObjectValues:function(e){return Object.values(e)},getElementStyle:function(e,t){var n=getComputedStyle(e);return t&&t in n?n[t]:n},getAttribute:function(e,t){return e.getAttribute(t)},setAttribute:function(e,t,n){return e.setAttribute(t,n)},removeAttribute:function(e,t){return e.removeAttribute(t)},Version:"0.2.23"}})); | ||
// shorter-js v0.2.24 | 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",r="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",u="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",c=/iPhone|iPad|iPod|Android/i,l=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return c.test(e.brand)})):c.test(navigator.userAgent),m=navigator.userAgentData,d=/(iPhone|iPod|iPad)/,v=m?m.brands.some((function(e){return d.test(e.brand)})):d.test(navigator.userAgent),f="webkitPerspective"in document.head.style||"perspective"in document.head.style;function g(e,t,n,i){var r=i||!1;e.addEventListener(t,n,r)}function p(e,t,n,i){var r=i||!1;e.removeEventListener(t,n,r)}function y(e,t,n,i){g(e,t,(function r(o){o.target===e&&(n.apply(e,[o]),p(e,t,r,i))}),i)}var E=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0}});y(document,"DOMContentLoaded",(function(){}),t)}catch(e){throw Error("Passive events are not supported")}return e}(),b="webkitTransform"in document.head.style||"transform"in document.head.style,h="ontouchstart"in window||"msMaxTouchPoints"in navigator,w="webkitAnimation"in document.head.style||"animation"in document.head.style,k="webkitTransition"in document.head.style||"transition"in document.head.style;var A=function(e){return"object"==typeof e&&e instanceof HTMLElement};function L(e,t){var n=t&&A(t)?t:document;return"object"==typeof e?e:n.querySelector(e)}var D=new Map,T={set:function(e,t,n,i){var r=L(e);A(r)&&(i&&i.length?(D.has(r)||D.set(r,new Map),D.get(r).set(i,setTimeout(t,n))):D.set(r,setTimeout(t,n)))},get:function(e,t){var n=L(e);if(!A(n))return null;if(t&&t.length){D.has(n)||D.set(n,new Map);var i=D.get(n);if(i.has(t))return i.get(t)}else if(D.has(n))return D.get(n);return null},clear:function(e,t){var n=L(e);if(A(n)&&D.has(n))if(t&&t.length){var i=D.get(n);i&&i.has(t)&&(clearTimeout(i.get(t)),i.delete(t))}else D.has(n)&&(clearTimeout(D.get(n)),D.delete(n))}},N=new Map,C={set:function(e,t,n){var i=L(e);A(i)&&(N.has(t)||N.set(t,new Map),N.get(t).set(i,n))},getAllFor:function(e){return N.has(e)?N.get(e):null},get:function(e,t){var n=L(e),i=C.getAllFor(t);return i&&A(n)&&i.has(n)?i.get(n):null},remove:function(e,t){var n=L(e);if(N.has(t)&&n){var i=N.get(t);i.delete(n),0===i.size&&N.delete(t)}}};function O(e,t){var n=getComputedStyle(e);return t&&t in n?n.getPropertyValue(t):""}function z(e){var t=O(e,"animationName"),n=O(e,"animationDelay"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function M(e){var t=O(e,"animationName"),n=O(e,"animationDuration"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function S(e){var t=O(e,i),r=O(e,n),o=r.includes("ms")?1:1e3,a=w&&t&&"none"!==t?parseFloat(r)*o:0;return Number.isNaN(a)?0:a}function I(e){var n=O(e,i),r=O(e,t),o=r.includes("ms")?1:1e3,a=w&&n&&"none"!==n?parseFloat(r)*o:0;return Number.isNaN(a)?0:a}function P(e){var t=O(e,"transitionProperty"),n=O(e,"transitionDelay"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function H(e){var t=O(e,"transitionProperty"),n=O(e,"transitionDuration"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function F(e){var t=O(e,u),n=O(e,a),i=n.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function B(e){var t=O(e,u),n=O(e,o),i=n.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function x(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}var j=function(e){return Object.keys(e)};var R=function(e,t){return Object.assign(e,t)};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:r,transitionDuration:"transitionDuration",transitionDurationLegacy:o,transitionDelay:"transitionDelay",transitionDelayLegacy:a,transitionEndEvent:"transitionend",transitionEndEventLegacy:s,transitionProperty:"transitionProperty",transitionPropertyLegacy:u,isMobile:l,isApple:v,support3DTransform:f,supportPassive:E,supportTransform:b,supportTouch:h,supportAnimation:w,supportTransition:k,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:"userAgentData",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:g,off:p,one:y,Data:C,Timer:T,getInstance:function(e,t){return C.get(e,t)},emulateAnimationEnd:function(e,t){var n=0,i=new Event("animationend"),r=M(e),o=z(e);if(r){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)}),r+o+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){var n=0,i=new Event(r),o=I(e),a=S(e);if(w&&o){var s=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(r,s),n=1)};e.addEventListener(r,s),setTimeout((function(){n||e.dispatchEvent(i)}),o+a+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){var n=0,i=new Event("transitionend"),r=H(e),o=P(e);if(r){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)}),r+o+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){var n=0,i=new Event(s),r=B(e),o=F(e);if(k&&r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(s,a),n=1)};e.addEventListener(s,a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+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=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!E&&{passive:!0},getElementAnimationDuration:M,getElementAnimationDurationLegacy:I,getElementAnimationDelay:z,getElementAnimationDelayLegacy:S,getElementTransitionDuration:H,getElementTransitionDurationLegacy:B,getElementTransitionDelay:P,getElementTransitionDelayLegacy:F,isArray:function(e){return Array.isArray(e)},isString:function(e){return e&&"string"==typeof e},isElement:function(e){return e&&e instanceof Element},isHTMLElement:A,isNodeList:function(e){return e instanceof NodeList},isHTMLCollection:function(e){return e instanceof HTMLCollection},isElementsArray:function(e){return Array.isArray(e)&&e.every((function(e){return A(e)}))},isMedia:function(e){return"object"==typeof e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(t){return e instanceof t}))},isRTL:function(){return"rtl"===document.documentElement.dir},queryElement:function(e,t){return L(e,t)},querySelector:L,querySelectorAll:function(e,t){return(t&&A(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&A(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&A(t)?t:document).getElementsByTagName(e)},normalizeValue:x,normalizeOptions:function(e,t,n,i){var r=Object.assign({},e.dataset),o={},a={};return j(r).forEach((function(e){var t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[t]=x(r[e])})),j(n).forEach((function(e){n[e]=x(n[e])})),j(t).forEach((function(e){o[e]=e in n?n[e]:e in a?a[e]:t[e]})),o},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(t+" "+e)}},reflow:function(e){return e.offsetHeight},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:j,ObjectValues:function(e){return Object.values(e)},getElementStyle:O,setElementStyle:function(e,t){return R(e.style,t)},getAttribute:function(e,t){return e.getAttribute(t)},setAttribute:function(e,t,n){return e.setAttribute(t,n)},removeAttribute:function(e,t){return e.removeAttribute(t)},Version:"0.2.24"}})); |
{ | ||
"name": "shorter-js", | ||
"version": "0.2.23", | ||
"version": "0.2.24", | ||
"description": "A small ES6+ library with various JavaScript tools useful for creating light libraries.", | ||
@@ -19,3 +19,4 @@ "main": "dist/shorter-js.min.js", | ||
"build:ts": "tsc -d", | ||
"build": "npm run lint:js && npm run umd && npm run umdmin && npm run esm && npm run esmmin", | ||
"build": "npm run lint:js && npm-run-all --parallel umd umdmin esm esmmin", | ||
"umd": "rollup --environment FORMAT:umd,MIN:false -c", | ||
@@ -43,4 +44,7 @@ "umdmin": "rollup --environment FORMAT:umd,MIN:true -c", | ||
"devDependencies": { | ||
"@rollup/plugin-buble": "^0.21.1", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"@rollup/plugin-buble": "^0.21.3", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^7.1.0", | ||
"@rollup/plugin-typescript": "^8.3.0", | ||
"npm-run-all": "^4.1.5", | ||
"eslint": "^7.22.0", | ||
@@ -50,6 +54,6 @@ "eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-vue": "^7.7.0", | ||
"rollup": "^1.31.1", | ||
"rollup-plugin-terser": "^5.2.0", | ||
"rollup": "^2.38.5", | ||
"rollup-plugin-terser": "^5.3.1", | ||
"typescript": "^4.5.2" | ||
} | ||
} |
@@ -0,12 +1,15 @@ | ||
import userAgentData from '../strings/userAgentData'; | ||
/** @type {Record<string, any>} */ | ||
// @ts-ignore | ||
const { userAgentData } = navigator; | ||
const agentData = navigator[userAgentData]; | ||
const appleBrands = /(iPhone|iPod|iPad)/; | ||
/** | ||
* A global namespace for Apple browsers. | ||
* A global boolean for Apple browsers. | ||
* @type {boolean} | ||
*/ | ||
const isApple = !userAgentData ? appleBrands.test(navigator.userAgent) | ||
: userAgentData.brands.some((x) => appleBrands.test(x.brand)); | ||
const isApple = !agentData ? appleBrands.test(navigator.userAgent) | ||
: agentData.brands.some((/** @type {Record<string, any>} */x) => appleBrands.test(x.brand)); | ||
export default isApple; |
@@ -0,8 +1,10 @@ | ||
import userAgentData from '../strings/userAgentData'; | ||
const mobileBrands = /iPhone|iPad|iPod|Android/i; | ||
const userAgentStr = 'userAgentData'; | ||
let isMobileCheck = false; | ||
if (navigator[userAgentStr]) { | ||
isMobileCheck = navigator[userAgentStr].brands.some((x) => mobileBrands.test(x.brand)); | ||
// @ts-ignore | ||
if (navigator[userAgentData]) { | ||
// @ts-ignore | ||
isMobileCheck = navigator[userAgentData].brands.some((x) => mobileBrands.test(x.brand)); | ||
} else { | ||
@@ -9,0 +11,0 @@ isMobileCheck = mobileBrands.test(navigator.userAgent); |
/** | ||
* A global namespace for CSS3 3D transform support. | ||
* A global `boolean` for CSS3 3D transform support. | ||
* @type {boolean} | ||
@@ -4,0 +4,0 @@ */ |
/** | ||
* A global namespace for CSS3 animation support. | ||
* A global `boolean` for CSS3 animation support. | ||
* @type {boolean} | ||
@@ -4,0 +4,0 @@ */ |
@@ -1,3 +0,3 @@ | ||
import addEventListener from '../strings/addEventListener.js'; | ||
import removeEventListener from '../strings/removeEventListener.js'; | ||
import DOMContentLoadedEvent from '../strings/DOMContentLoadedEvent'; | ||
import one from '../event/one'; | ||
@@ -17,5 +17,3 @@ /** | ||
}); | ||
document[addEventListener]('DOMContentLoaded', function wrap() { | ||
document[removeEventListener]('DOMContentLoaded', wrap, opts); | ||
}, opts); | ||
one(document, DOMContentLoadedEvent, () => {}, opts); | ||
} catch (e) { | ||
@@ -22,0 +20,0 @@ throw Error('Passive events are not supported'); |
/** | ||
* Remove eventListener from Element | ||
* Remove eventListener from an `HTMLElement` | `Document` target. | ||
* | ||
* @param {Element} element event.target | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
@@ -9,0 +9,0 @@ export default function off(element, eventName, handler, options) { |
/** | ||
* Add eventListener to Element | ||
* Add eventListener to an `HTMLElement` | `Document` target. | ||
* | ||
* @param {Element} element event.target | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
@@ -9,0 +9,0 @@ export default function on(element, eventName, handler, options) { |
@@ -5,9 +5,9 @@ import on from './on'; | ||
/** | ||
* Add an eventListener to Element | ||
* Add an `eventListener` to an `HTMLElement` | `Document` target | ||
* and remove it once callback is called. | ||
* | ||
* @param {Element} element event.target | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
@@ -14,0 +14,0 @@ export default function one(element, eventName, handler, options) { |
@@ -95,9 +95,18 @@ // strings | ||
import animationDuration from './strings/animationDuration'; | ||
import animationDurationLegacy from './strings/animationDurationLegacy'; | ||
import animationDelay from './strings/animationDelay'; | ||
import animationDelayLegacy from './strings/animationDelayLegacy'; | ||
import animationName from './strings/animationName'; | ||
import animationNameLegacy from './strings/animationNameLegacy'; | ||
import animationEndEvent from './strings/animationEndEvent'; | ||
import animationEndEventLegacy from './strings/animationEndEventLegacy'; | ||
import transitionDuration from './strings/transitionDuration'; | ||
import transitionDurationLegacy from './strings/transitionDurationLegacy'; | ||
import transitionDelay from './strings/transitionDelay'; | ||
import transitionDelayLegacy from './strings/transitionDelayLegacy'; | ||
import transitionEndEvent from './strings/transitionEndEvent'; | ||
import transitionEndEventLegacy from './strings/transitionEndEventLegacy'; | ||
import transitionProperty from './strings/transitionProperty'; | ||
import transitionPropertyLegacy from './strings/transitionPropertyLegacy'; | ||
import addEventListener from './strings/addEventListener'; | ||
@@ -113,2 +122,4 @@ import removeEventListener from './strings/removeEventListener'; | ||
import userAgentData from './strings/userAgentData'; | ||
// boolean | ||
@@ -138,12 +149,15 @@ import isMobile from './boolean/isMobile'; | ||
import emulateAnimationEnd from './misc/emulateAnimationEnd'; | ||
import emulateAnimationEndLegacy from './misc/emulateAnimationEndLegacy'; | ||
import emulateTransitionEnd from './misc/emulateTransitionEnd'; | ||
import isElementInScrollRange from './misc/isElementInScrollRange'; | ||
import isElementInViewport from './misc/isElementInViewport'; | ||
import isMedia from './misc/isMedia'; | ||
import isRTL from './misc/isRTL'; | ||
import emulateTransitionEndLegacy from './misc/emulateTransitionEndLegacy'; | ||
import passiveHandler from './misc/passiveHandler'; | ||
import getElementAnimationDuration from './misc/getElementAnimationDuration'; | ||
import getElementAnimationDurationLegacy from './misc/getElementAnimationDurationLegacy'; | ||
import getElementAnimationDelay from './misc/getElementAnimationDelay'; | ||
import getElementAnimationDelayLegacy from './misc/getElementAnimationDelayLegacy'; | ||
import getElementTransitionDuration from './misc/getElementTransitionDuration'; | ||
import getElementTransitionDurationLegacy from './misc/getElementTransitionDurationLegacy'; | ||
import getElementTransitionDelay from './misc/getElementTransitionDelay'; | ||
import getElementTransitionDelayLegacy from './misc/getElementTransitionDelayLegacy'; | ||
import normalizeValue from './misc/normalizeValue'; | ||
@@ -165,3 +179,9 @@ import normalizeOptions from './misc/normalizeOptions'; | ||
import removeAttribute from './misc/removeAttribute'; | ||
import setElementStyle from './misc/setElementStyle'; | ||
import isElementInScrollRange from './misc/isElementInScrollRange'; | ||
import isElementInViewport from './misc/isElementInViewport'; | ||
import isMedia from './misc/isMedia'; | ||
import isRTL from './misc/isRTL'; | ||
import isString from './misc/isString'; | ||
import isArray from './misc/isArray'; | ||
@@ -174,4 +194,4 @@ import isElement from './misc/isElement'; | ||
import querySelector from './misc/querySelector'; | ||
import queryElement from './misc/queryElement'; | ||
import querySelector from './misc/querySelector'; | ||
import querySelectorAll from './misc/querySelectorAll'; | ||
@@ -247,9 +267,17 @@ import getElementsByTagName from './misc/getElementsByTagName'; | ||
animationDuration, | ||
animationDurationLegacy, | ||
animationDelay, | ||
animationDelayLegacy, | ||
animationName, | ||
animationNameLegacy, | ||
animationEndEvent, | ||
animationEndEventLegacy, | ||
transitionDuration, | ||
transitionDurationLegacy, | ||
transitionDelay, | ||
transitionDelayLegacy, | ||
transitionEndEvent, | ||
transitionEndEventLegacy, | ||
transitionProperty, | ||
transitionPropertyLegacy, | ||
isMobile, | ||
@@ -291,2 +319,3 @@ isApple, | ||
scrollWidth, | ||
userAgentData, | ||
addClass, | ||
@@ -302,3 +331,5 @@ removeClass, | ||
emulateAnimationEnd, | ||
emulateAnimationEndLegacy, | ||
emulateTransitionEnd, | ||
emulateTransitionEndLegacy, | ||
isElementInScrollRange, | ||
@@ -308,6 +339,11 @@ isElementInViewport, | ||
getElementAnimationDuration, | ||
getElementAnimationDurationLegacy, | ||
getElementAnimationDelay, | ||
getElementAnimationDelayLegacy, | ||
getElementTransitionDuration, | ||
getElementTransitionDurationLegacy, | ||
getElementTransitionDelay, | ||
getElementTransitionDelayLegacy, | ||
isArray, | ||
isString, | ||
isElement, | ||
@@ -336,2 +372,3 @@ isHTMLElement, | ||
getElementStyle, | ||
setElementStyle, | ||
getAttribute, | ||
@@ -338,0 +375,0 @@ setAttribute, |
@@ -5,5 +5,5 @@ /** | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Array} | ||
* @returns {Array<any>} | ||
*/ | ||
const ArrayFrom = (arr) => Array.from(arr); | ||
export default ArrayFrom; |
import querySelector from './querySelector'; | ||
import isElement from './isElement'; | ||
import isHTMLElement from './isHTMLElement'; | ||
@@ -12,9 +12,9 @@ const componentData = new Map(); | ||
* Sets web components data. | ||
* @param {Element | string} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @param {any} instance the component instance | ||
*/ | ||
set: (element, component, instance) => { | ||
const ELEMENT = querySelector(element); | ||
if (!isElement(ELEMENT)) return; | ||
set: (target, component, instance) => { | ||
const element = querySelector(target); | ||
if (!isHTMLElement(element)) return; | ||
@@ -26,3 +26,3 @@ if (!componentData.has(component)) { | ||
const instanceMap = componentData.get(component); | ||
instanceMap.set(ELEMENT, instance); | ||
instanceMap.set(element, instance); | ||
}, | ||
@@ -44,12 +44,12 @@ | ||
* Returns the instance associated with the target. | ||
* @param {Element | string} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any?} the instance | ||
*/ | ||
get: (element, component) => { | ||
const ELEMENT = querySelector(element); | ||
get: (target, component) => { | ||
const element = querySelector(target); | ||
const allForC = Data.getAllFor(component); | ||
if (allForC && isElement(ELEMENT) && allForC.has(ELEMENT)) { | ||
return allForC.get(ELEMENT); | ||
if (allForC && isHTMLElement(element) && allForC.has(element)) { | ||
return allForC.get(element); | ||
} | ||
@@ -61,7 +61,8 @@ return null; | ||
* Removes web components data. | ||
* @param {Element} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
*/ | ||
remove: (element, component) => { | ||
if (!componentData.has(component)) return; | ||
remove: (target, component) => { | ||
const element = querySelector(target); | ||
if (!componentData.has(component) || !element) return; | ||
@@ -79,8 +80,8 @@ const instanceMap = componentData.get(component); | ||
* An alias for `Data.get()`. | ||
* @param {Element | string} element target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any} the request result | ||
* @returns {Record<string, any>?} the request result | ||
*/ | ||
export const getInstance = (element, component) => Data.get(element, component); | ||
export const getInstance = (target, component) => Data.get(target, component); | ||
export default Data; |
@@ -9,3 +9,3 @@ import animationEndEvent from '../strings/animationEndEvent'; | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `animationend` callback | ||
@@ -12,0 +12,0 @@ */ |
@@ -9,3 +9,3 @@ import transitionEndEvent from '../strings/transitionEndEvent'; | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `transitionend` callback | ||
@@ -12,0 +12,0 @@ */ |
@@ -6,6 +6,3 @@ /** | ||
*/ | ||
const Float32ArrayFrom = (arr) => { | ||
const array = Array.from(arr); | ||
return Float32Array.from(array); | ||
}; | ||
const Float32ArrayFrom = (arr) => Float32Array.from(Array.from(arr)); | ||
export default Float32ArrayFrom; |
@@ -6,6 +6,3 @@ /** | ||
*/ | ||
const Float64ArrayFrom = (arr) => { | ||
const array = Array.from(arr); | ||
return Float64Array.from(array); | ||
}; | ||
const Float64ArrayFrom = (arr) => Float64Array.from(Array.from(arr)); | ||
export default Float64ArrayFrom; |
/** | ||
* Shortcut for `Element.getAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.getAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
@@ -5,0 +5,0 @@ */ |
@@ -1,4 +0,4 @@ | ||
import supportAnimation from '../boolean/supportAnimation'; | ||
import animationDelay from '../strings/animationDelay'; | ||
import animationName from '../strings/animationName'; | ||
import getElementStyle from './getElementStyle'; | ||
@@ -9,11 +9,11 @@ /** | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementAnimationDelay(element) { | ||
const computedStyle = getComputedStyle(element); | ||
const propertyValue = computedStyle[animationName]; | ||
const durationValue = computedStyle[animationDelay]; | ||
const propertyValue = getElementStyle(element, animationName); | ||
const durationValue = getElementStyle(element, animationDelay); | ||
const durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
const duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
const duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
@@ -20,0 +20,0 @@ |
@@ -1,18 +0,17 @@ | ||
import supportAnimation from '../boolean/supportAnimation'; | ||
import animationDuration from '../strings/animationDuration'; | ||
import animationName from '../strings/animationName'; | ||
import getElementStyle from './getElementStyle'; | ||
/** | ||
* Utility to get the computed `animationDuration` | ||
* from Element in miliseconds. | ||
* from `HTMLElement` in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementAnimationDuration(element) { | ||
const computedStyle = getComputedStyle(element); | ||
const propertyValue = computedStyle[animationName]; | ||
const durationValue = computedStyle[animationDuration]; | ||
const propertyValue = getElementStyle(element, animationName); | ||
const durationValue = getElementStyle(element, animationDuration); | ||
const durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
const duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
const duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
@@ -19,0 +18,0 @@ |
@@ -1,13 +0,13 @@ | ||
import isElement from './isElement'; | ||
import isHTMLElement from './isHTMLElement'; | ||
/** | ||
* Shortcut for `Element.getElementsByClassName` method. | ||
* Shortcut for `HTMLElement.getElementsByClassName` method. | ||
* | ||
* @param {string} selector the class name | ||
* @param {Element=} parent optional Element to look into | ||
* @return {HTMLCollection} the 'HTMLCollection' | ||
* @param {(HTMLElement)=} parent optional Element to look into | ||
* @return {HTMLCollectionOf<HTMLElement | Element>} the 'HTMLCollection' | ||
*/ | ||
export default function getElementsByClassName(selector, parent) { | ||
const lookUp = parent && isElement(parent) ? parent : document; | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return lookUp.getElementsByClassName(selector); | ||
} |
@@ -1,13 +0,13 @@ | ||
import isElement from './isElement'; | ||
import isHTMLElement from './isHTMLElement'; | ||
/** | ||
* Shortcut for `Element.getElementsByTagName` method. | ||
* Shortcut for `HTMLElement.getElementsByTagName` method. | ||
* | ||
* @param {string} selector the tag name | ||
* @param {Element=} parent optional Element to look into | ||
* @return {HTMLCollection} the 'HTMLCollection' | ||
* @param {HTMLElement=} parent optional Element to look into | ||
* @return {HTMLCollectionOf<Element | HTMLElement>} the 'HTMLCollection' | ||
*/ | ||
export default function getElementsByTagName(selector, parent) { | ||
const lookUp = parent && isElement(parent) ? parent : document; | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return lookUp.getElementsByTagName(selector); | ||
} |
/** | ||
* Shortcut for `window.getComputedStyle(element).propertyName` | ||
* static method. | ||
* * If `element` parameter is not an `Element`, `getComputedStyle` | ||
* | ||
* * If `element` parameter is not an `HTMLElement`, `getComputedStyle` | ||
* throws a `ReferenceError`. | ||
* * If no property is defined, the entire `CSSStyleDeclaration` | ||
* instance is returned. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string=} property the css property | ||
@@ -17,4 +16,4 @@ * @return {string} the css property value | ||
return property && property in computedStyle | ||
? computedStyle[property] | ||
: computedStyle; | ||
? computedStyle.getPropertyValue(property) | ||
: ''; | ||
} |
@@ -1,4 +0,4 @@ | ||
import supportTransition from '../boolean/supportTransition'; | ||
import transitionDelay from '../strings/transitionDelay'; | ||
import transitionProperty from '../strings/transitionProperty'; | ||
import getElementStyle from './getElementStyle'; | ||
@@ -9,11 +9,11 @@ /** | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementTransitionDelay(element) { | ||
const computedStyle = getComputedStyle(element); | ||
const propertyValue = computedStyle[transitionProperty]; | ||
const delayValue = computedStyle[transitionDelay]; | ||
const propertyValue = getElementStyle(element, transitionProperty); | ||
const delayValue = getElementStyle(element, transitionDelay); | ||
const delayScale = delayValue.includes('ms') ? 1 : 1000; | ||
const duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
const duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(delayValue) * delayScale : 0; | ||
@@ -20,0 +20,0 @@ |
@@ -1,4 +0,4 @@ | ||
import supportTransition from '../boolean/supportTransition'; | ||
import transitionDuration from '../strings/transitionDuration'; | ||
import transitionProperty from '../strings/transitionProperty'; | ||
import getElementStyle from './getElementStyle'; | ||
@@ -9,11 +9,10 @@ /** | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementTransitionDuration(element) { | ||
const computedStyle = getComputedStyle(element); | ||
const propertyValue = computedStyle[transitionProperty]; | ||
const durationValue = computedStyle[transitionDuration]; | ||
const propertyValue = getElementStyle(element, transitionProperty); | ||
const durationValue = getElementStyle(element, transitionDuration); | ||
const durationScale = durationValue.includes('ms') ? 1 : 1000; | ||
const duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
const duration = propertyValue && propertyValue !== 'none' | ||
? parseFloat(durationValue) * durationScale : 0; | ||
@@ -20,0 +19,0 @@ |
@@ -8,2 +8,3 @@ /** | ||
const isArray = (arr) => Array.isArray(arr); | ||
export default isArray; |
@@ -7,4 +7,4 @@ /** | ||
*/ | ||
export default function isElement(element) { | ||
return element instanceof Element; | ||
} | ||
const isElement = (element) => element && element instanceof Element; | ||
export default isElement; |
/** | ||
* Utility to determine if an `Element` | ||
* Utility to determine if an `HTMLElement` | ||
* is partially visible in viewport. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
@@ -7,0 +7,0 @@ */ |
/** | ||
* Utility to determine if an `Element` | ||
* Utility to determine if an `HTMLElement` | ||
* is fully visible in the viewport. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
@@ -7,0 +7,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
import isElement from './isElement'; | ||
import isHTMLElement from './isHTMLElement'; | ||
@@ -9,4 +9,5 @@ /** | ||
*/ | ||
export default function isElementsArray(object) { | ||
return Array.isArray(object) && object.every((el) => isElement(el)); | ||
} | ||
const isElementsArray = (object) => Array.isArray(object) | ||
&& object.every((el) => isHTMLElement(el)); | ||
export default isElementsArray; |
@@ -7,4 +7,3 @@ /** | ||
*/ | ||
export default function isHTMLCollection(object) { | ||
return object instanceof HTMLCollection; | ||
} | ||
const isHTMLCollection = (object) => object instanceof HTMLCollection; | ||
export default isHTMLCollection; |
@@ -7,4 +7,3 @@ /** | ||
*/ | ||
export default function isHTMLElement(element) { | ||
return element instanceof HTMLElement; | ||
} | ||
const isHTMLElement = (element) => typeof element === 'object' && element instanceof HTMLElement; | ||
export default isHTMLElement; |
@@ -7,5 +7,5 @@ /** | ||
*/ | ||
export default function isMedia(element) { | ||
return [SVGElement, HTMLImageElement, HTMLVideoElement] | ||
const isMedia = (element) => typeof element === 'object' | ||
&& [SVGElement, HTMLImageElement, HTMLVideoElement] | ||
.some((mediaType) => element instanceof mediaType); | ||
} | ||
export default isMedia; |
@@ -7,4 +7,3 @@ /** | ||
*/ | ||
export default function isNodeList(object) { | ||
return object instanceof NodeList; | ||
} | ||
const isNodeList = (object) => object instanceof NodeList; | ||
export default isNodeList; |
@@ -7,3 +7,3 @@ import normalizeValue from './normalizeValue'; | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {Record<string, any>} defaultOps component default options | ||
@@ -15,5 +15,6 @@ * @param {Record<string, any>} inputOps component instance options | ||
export default function normalizeOptions(element, defaultOps, inputOps, ns) { | ||
// @ts-ignore -- usually our `Element` is `HTMLElement` as well | ||
const data = { ...element.dataset }; | ||
/** @type {Record<string, any>} */ | ||
const normalOps = {}; | ||
/** @type {Record<string, any>} */ | ||
const dataOps = {}; | ||
@@ -20,0 +21,0 @@ |
/** | ||
* The raw value or a given component option. | ||
* | ||
* @typedef {string | Element | Function | number | boolean | null} niceValue | ||
* @typedef {string | HTMLElement | Function | number | boolean | null} niceValue | ||
*/ | ||
@@ -30,4 +30,4 @@ | ||
// string / function / Element / object | ||
// string / function / HTMLElement / object | ||
return value; | ||
} |
import querySelector from './querySelector'; | ||
/** | ||
* Utility to check if target is typeof `Element` | ||
* Utility to check if target is typeof `HTMLElement` | ||
* or find one that matches a selector. | ||
@@ -9,5 +9,5 @@ * | ||
* | ||
* @param {Element | string} selector the input selector or target element | ||
* @param {Element=} parent optional Element to look into | ||
* @return {Element?} the Element or `querySelector` result | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {(ParentNode | HTMLElement)=} parent optional `HTMLElement` to look into | ||
* @return {HTMLElement?} the Element or `querySelector` result | ||
*/ | ||
@@ -14,0 +14,0 @@ export default function queryElement(selector, parent) { |
@@ -1,15 +0,14 @@ | ||
import isElement from './isElement'; | ||
import isHTMLElement from './isHTMLElement'; | ||
/** | ||
* Utility to check if target is typeof `Element` | ||
* Utility to check if target is typeof `HTMLElement` | ||
* or find one that matches a selector. | ||
* | ||
* @param {Element | string} selector the input selector or target element | ||
* @param {Element=} parent optional Element to look into | ||
* @return {Element?} the Element or `querySelector` result | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {(ParentNode | HTMLElement)=} parent optional `HTMLElement` to look into | ||
* @return {HTMLElement?} the `HTMLElement` or `querySelector` result | ||
*/ | ||
export default function querySelector(selector, parent) { | ||
const lookUp = parent && isElement(parent) ? parent : document; | ||
// @ts-ignore -- `isElement` is just as good | ||
return isElement(selector) ? selector : lookUp.querySelector(selector); | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return typeof selector === 'object' ? selector : lookUp.querySelector(selector); | ||
} |
@@ -1,2 +0,2 @@ | ||
import isElement from './isElement'; | ||
import isHTMLElement from './isHTMLElement'; | ||
@@ -7,8 +7,8 @@ /** | ||
* @param {string} selector the input selector | ||
* @param {ParentNode=} parent optional Element to look into | ||
* @return {NodeList} the query result | ||
* @param {(HTMLElement | ParentNode)=} parent optional Element to look into | ||
* @return {NodeListOf<HTMLElement>} the query result | ||
*/ | ||
export default function querySelectorAll(selector, parent) { | ||
const lookUp = parent && isElement(parent) ? parent : document; | ||
const lookUp = parent && isHTMLElement(parent) ? parent : document; | ||
return lookUp.querySelectorAll(selector); | ||
} |
/** | ||
* Utility to force re-paint of an `Element` target. | ||
* Utility to force re-paint of an `HTMLElement` target. | ||
* | ||
* @param {Element | HTMLElement} element is the target | ||
* @param {HTMLElement} element is the target | ||
* @return {number} the `Element.offsetHeight` value | ||
*/ | ||
export default function reflow(element) { | ||
// @ts-ignore -- our `Element` is always an `HTMLElement` | ||
return element.offsetHeight; | ||
} | ||
const reflow = (element) => element.offsetHeight; | ||
export default reflow; |
/** | ||
* Shortcut for `Element.removeAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.removeAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
@@ -5,0 +5,0 @@ */ |
/** | ||
* Shortcut for `Element.setAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.setAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
@@ -5,0 +5,0 @@ * @param {string} value attribute value |
@@ -1,10 +0,13 @@ | ||
import isElement from './isElement'; | ||
import isHTMLElement from './isHTMLElement'; | ||
import querySelector from './querySelector'; | ||
const TimeCache = new Map(); | ||
/** | ||
* An interface for one or more `TimerHandler`s per `Element`. | ||
* @see https://github.com/thednp/navbar.js/ | ||
*/ | ||
const Timer = { | ||
/** | ||
* Sets a new timeout timer for an element, or element -> key association. | ||
* @param {Element | string} target target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {ReturnType<TimerHandler>} callback the callback | ||
@@ -16,5 +19,6 @@ * @param {number} delay the execution delay | ||
const element = querySelector(target); | ||
if (!isElement(element)) return; | ||
if (typeof key === 'string' && key.length) { | ||
if (!isHTMLElement(element)) return; | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
@@ -32,3 +36,3 @@ TimeCache.set(element, new Map()); | ||
* Returns the timer associated with the target. | ||
* @param {Element | string} target target element | ||
* @param {HTMLElement | string} target target element | ||
* @param {string=} key a unique | ||
@@ -39,5 +43,6 @@ * @returns {Map<Element, TimerHandler>?} the timer | ||
const element = querySelector(target); | ||
if (!isElement(element)) return null; | ||
if (typeof key === 'string' && key.length) { | ||
if (!isHTMLElement(element)) return null; | ||
if (key && key.length) { | ||
if (!TimeCache.has(element)) { | ||
@@ -58,3 +63,3 @@ TimeCache.set(element, new Map()); | ||
* Clears the element's timer. | ||
* @param {Element} target target element | ||
* @param {HTMLElement} target target element | ||
* @param {string=} key a unique | ||
@@ -65,5 +70,5 @@ */ | ||
if (!isElement(element) || !TimeCache.has(element)) return; | ||
if (!isHTMLElement(element) || !TimeCache.has(element)) return; | ||
if (typeof key === 'string' && key.length) { | ||
if (key && key.length) { | ||
const keyTimers = TimeCache.get(element); | ||
@@ -70,0 +75,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
const animationDelay = 'webkitAnimation' in document.head.style ? 'webkitAnimationDelay' : 'animationDelay'; | ||
const animationDelay = 'animationDelay'; | ||
export default animationDelay; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
const animationDuration = 'webkitAnimation' in document.head.style ? 'webkitAnimationDuration' : 'animationDuration'; | ||
const animationDuration = 'animationDuration'; | ||
export default animationDuration; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
const animationEndEvent = 'webkitAnimation' in document.head.style ? 'webkitAnimationEnd' : 'animationend'; | ||
const animationEndEvent = 'animationend'; | ||
export default animationEndEvent; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
const animationName = 'webkitAnimation' in document.head.style ? 'webkitAnimationName' : 'animationName'; | ||
const animationName = 'animationName'; | ||
export default animationName; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
const transitionDelay = 'webkitTransition' in document.head.style ? 'webkitTransitionDelay' : 'transitionDelay'; | ||
const transitionDelay = 'transitionDelay'; | ||
export default transitionDelay; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
const transitionDuration = 'webkitTransition' in document.head.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
const transitionDuration = 'transitionDuration'; | ||
export default transitionDuration; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
const transitionEndEvent = 'webkitTransition' in document.head.style ? 'webkitTransitionEnd' : 'transitionend'; | ||
const transitionEndEvent = 'transitionend'; | ||
export default transitionEndEvent; |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
const transitionProperty = 'webkitTransition' in document.head.style ? 'webkitTransitionProperty' : 'transitionProperty'; | ||
const transitionProperty = 'transitionProperty'; | ||
export default transitionProperty; |
@@ -88,9 +88,17 @@ export as namespace SHORTER; | ||
export { default as animationDuration } from "shorter-js/src/strings/animationDuration"; | ||
export { default as animationDurationLegacy } from "shorter-js/src/strings/animationDurationLegacy"; | ||
export { default as animationDelay } from "shorter-js/src/strings/animationDelay"; | ||
export { default as animationDelayLegacy } from "shorter-js/src/strings/animationDelayLegacy"; | ||
export { default as animationName } from "shorter-js/src/strings/animationName"; | ||
export { default as animationNameLegacy } from "shorter-js/src/strings/animationNameLegacy"; | ||
export { default as animationEndEvent } from "shorter-js/src/strings/animationEndEvent"; | ||
export { default as animationEndEventLegacy } from "shorter-js/src/strings/animationEndEventLegacy"; | ||
export { default as transitionDuration } from "shorter-js/src/strings/transitionDuration"; | ||
export { default as transitionDurationLegacy } from "shorter-js/src/strings/transitionDurationLegacy"; | ||
export { default as transitionDelay } from "shorter-js/src/strings/transitionDelay"; | ||
export { default as transitionDelayLegacy } from "shorter-js/src/strings/transitionDelayLegacy"; | ||
export { default as transitionEndEvent } from "shorter-js/src/strings/transitionEndEvent"; | ||
export { default as transitionEndEventLegacy } from "shorter-js/src/strings/transitionEndEventLegacy"; | ||
export { default as transitionProperty } from "shorter-js/src/strings/transitionProperty"; | ||
export { default as transitionPropertyLegacy } from "shorter-js/src/strings/transitionPropertyLegacy"; | ||
export { default as addEventListener } from "shorter-js/src/strings/addEventListener"; | ||
@@ -120,11 +128,18 @@ export { default as removeEventListener } from "shorter-js/src/strings/removeEventListener"; | ||
export { default as emulateAnimationEnd } from "shorter-js/src/misc/emulateAnimationEnd"; | ||
export { default as emulateAnimationEndLegacy } from "shorter-js/src/misc/emulateAnimationEndLegacy"; | ||
export { default as emulateTransitionEnd } from "shorter-js/src/misc/emulateTransitionEnd"; | ||
export { default as emulateTransitionEndLegacy } from "shorter-js/src/misc/emulateTransitionEndLegacy"; | ||
export { default as isElementInScrollRange } from "shorter-js/src/misc/isElementInScrollRange"; | ||
export { default as isElementInViewport } from "shorter-js/src/misc/isElementInViewport"; | ||
export { default as isMedia } from "shorter-js/src/misc/isMedia"; | ||
export { default as isRTL } from "shorter-js/src/misc/isRTL"; | ||
export { default as passiveHandler } from "shorter-js/src/misc/passiveHandler"; | ||
export { default as getElementAnimationDuration } from "shorter-js/src/misc/getElementAnimationDuration"; | ||
export { default as getElementAnimationDurationLegacy } from "shorter-js/src/misc/getElementAnimationDurationLegacy"; | ||
export { default as getElementAnimationDelay } from "shorter-js/src/misc/getElementAnimationDelay"; | ||
export { default as getElementAnimationDelayLegacy } from "shorter-js/src/misc/getElementAnimationDelayLegacy"; | ||
export { default as getElementTransitionDuration } from "shorter-js/src/misc/getElementTransitionDuration"; | ||
export { default as getElementTransitionDurationLegacy } from "shorter-js/src/misc/getElementTransitionDurationLegacy"; | ||
export { default as getElementTransitionDelay } from "shorter-js/src/misc/getElementTransitionDelay"; | ||
export { default as getElementTransitionDelayLegacy } from "shorter-js/src/misc/getElementTransitionDelayLegacy"; | ||
export { default as normalizeValue } from "shorter-js/src/misc/normalizeValue"; | ||
@@ -140,11 +155,12 @@ export { default as normalizeOptions } from "shorter-js/src/misc/normalizeOptions"; | ||
export { default as ObjectAssign } from "shorter-js/src/misc/ObjectAssign"; | ||
export { default as getElementStyle } from "shorter-js/src/misc/getElementStyle"; | ||
export { default as getAttribute } from "shorter-js/src/misc/getAttribute"; | ||
export { default as setAttribute } from "shorter-js/src/misc/setAttribute"; | ||
export { default as removeAttribute } from "shorter-js/src/misc/removeAttribute"; | ||
export { default as isHTMLElement } from "shorter-js/src/misc/isHTMLElement"; | ||
export { default as isMedia } from "shorter-js/src/misc/isMedia"; | ||
export { default as getElementStyle } from "shorter-js/src/misc/getElementStyle"; | ||
export { default as setElementStyle } from "shorter-js/src/misc/setElementStyle"; | ||
export { default as isArray } from "shorter-js/src/misc/isArray"; | ||
export { default as isString } from "shorter-js/src/misc/isString"; | ||
export { default as isElement } from "shorter-js/src/misc/isElement"; | ||
export { default as isNodeList } from "shorter-js/src/misc/isNodeList"; | ||
export { default as isHTMLElement } from "shorter-js/src/misc/isHTMLElement"; | ||
export { default as isHTMLCollection } from "shorter-js/src/misc/isHTMLCollection"; | ||
@@ -151,0 +167,0 @@ export { default as isElementsArray } from "shorter-js/src/misc/isElementsArray"; |
@@ -95,9 +95,18 @@ // strings | ||
export { default as animationDuration } from "../../src/strings/animationDuration"; | ||
export { default as animationDurationLegacy } from "../../src/strings/animationDurationLegacy"; | ||
export { default as animationDelay } from "../../src/strings/animationDelay"; | ||
export { default as animationDelayLegacy } from "../../src/strings/animationDelayLegacy"; | ||
export { default as animationName } from "../../src/strings/animationName"; | ||
export { default as animationNameLegacy } from "../../src/strings/animationNameLegacy"; | ||
export { default as animationEndEvent } from "../../src/strings/animationEndEvent"; | ||
export { default as animationEndEventLegacy } from "../../src/strings/animationEndEventLegacy"; | ||
export { default as transitionDuration } from "../../src/strings/transitionDuration"; | ||
export { default as transitionDurationLegacy } from "../../src/strings/transitionDurationLegacy"; | ||
export { default as transitionDelay } from "../../src/strings/transitionDelay"; | ||
export { default as transitionDelayLegacy } from "../../src/strings/transitionDelayLegacy"; | ||
export { default as transitionEndEvent } from "../../src/strings/transitionEndEvent"; | ||
export { default as transitionEndEventLegacy } from "../../src/strings/transitionEndEventLegacy"; | ||
export { default as transitionProperty } from "../../src/strings/transitionProperty"; | ||
export { default as transitionPropertyLegacy } from "../../src/strings/transitionPropertyLegacy"; | ||
export { default as addEventListener } from "../../src/strings/addEventListener"; | ||
@@ -137,3 +146,5 @@ export { default as removeEventListener } from "../../src/strings/removeEventListener"; | ||
export { default as emulateAnimationEnd } from "../../src/misc/emulateAnimationEnd"; | ||
export { default as emulateAnimationEndLegacy } from "../../src/misc/emulateAnimationEndLegacy"; | ||
export { default as emulateTransitionEnd } from "../../src/misc/emulateTransitionEnd"; | ||
export { default as emulateTransitionEndLegacy } from "../../src/misc/emulateTransitionEndLegacy"; | ||
export { default as isElementInScrollRange } from "../../src/misc/isElementInScrollRange"; | ||
@@ -145,5 +156,9 @@ export { default as isElementInViewport } from "../../src/misc/isElementInViewport"; | ||
export { default as getElementAnimationDuration } from "../../src/misc/getElementAnimationDuration"; | ||
export { default as getElementAnimationDurationLegacy } from "../../src/misc/getElementAnimationDurationLegacy"; | ||
export { default as getElementAnimationDelay } from "../../src/misc/getElementAnimationDelay"; | ||
export { default as getElementAnimationDelayLegacy } from "../../src/misc/getElementAnimationDelayLegacy"; | ||
export { default as getElementTransitionDuration } from "../../src/misc/getElementTransitionDuration"; | ||
export { default as getElementTransitionDurationLegacy } from "../../src/misc/getElementTransitionDurationLegacy"; | ||
export { default as getElementTransitionDelay } from "../../src/misc/getElementTransitionDelay"; | ||
export { default as getElementTransitionDelayLegacy } from "../../src/misc/getElementTransitionDelayLegacy"; | ||
export { default as normalizeValue } from "../../src/misc/normalizeValue"; | ||
@@ -160,3 +175,3 @@ export { default as normalizeOptions } from "../../src/misc/normalizeOptions"; | ||
export { default as ObjectAssign } from '../../src/misc/ObjectAssign'; | ||
export { default as getElementStyle } from '../../src/misc/getElementStyle'; | ||
export { default as getAttribute } from '../../src/misc/getAttribute'; | ||
@@ -166,6 +181,10 @@ export { default as setAttribute } from '../../src/misc/setAttribute'; | ||
export { default as isHTMLElement } from "../../src/misc/isHTMLElement"; | ||
export { default as getElementStyle } from '../../src/misc/getElementStyle'; | ||
export { default as setElementStyle } from '../../src/misc/setElementStyle'; | ||
export { default as isArray } from "../../src/misc/isArray"; | ||
export { default as isString } from "../../src/misc/isString"; | ||
export { default as isElement } from "../../src/misc/isElement"; | ||
export { default as isNodeList } from "../../src/misc/isNodeList"; | ||
export { default as isHTMLElement } from "../../src/misc/isHTMLElement"; | ||
export { default as isHTMLCollection } from "../../src/misc/isHTMLCollection"; | ||
@@ -172,0 +191,0 @@ export { default as isElementsArray } from "../../src/misc/isElementsArray"; |
@@ -676,2 +676,10 @@ declare module "shorter-js/src/strings/ariaChecked" { | ||
} | ||
declare module "shorter-js/src/strings/animationDurationLegacy" { | ||
export default animationDuration; | ||
/** | ||
* A global namespace for 'animationDuration' string. | ||
* @type {string} | ||
*/ | ||
const animationDuration: string; | ||
} | ||
declare module "shorter-js/src/strings/animationDelay" { | ||
@@ -685,2 +693,10 @@ export default animationDelay; | ||
} | ||
declare module "shorter-js/src/strings/animationDelayLegacy" { | ||
export default animationDelay; | ||
/** | ||
* A global namespace for 'animationDelay' string. | ||
* @type {string} | ||
*/ | ||
const animationDelay: string; | ||
} | ||
declare module "shorter-js/src/strings/animationName" { | ||
@@ -694,2 +710,10 @@ export default animationName; | ||
} | ||
declare module "shorter-js/src/strings/animationNameLegacy" { | ||
export default animationName; | ||
/** | ||
* A global namespace for 'animationName' string. | ||
* @type {string} | ||
*/ | ||
const animationName: string; | ||
} | ||
declare module "shorter-js/src/strings/animationEndEvent" { | ||
@@ -703,2 +727,10 @@ export default animationEndEvent; | ||
} | ||
declare module "shorter-js/src/strings/animationEndEventLegacy" { | ||
export default animationEndEvent; | ||
/** | ||
* A global namespace for 'animationend' string. | ||
* @type {string} | ||
*/ | ||
const animationEndEvent: string; | ||
} | ||
declare module "shorter-js/src/strings/transitionDuration" { | ||
@@ -712,2 +744,10 @@ export default transitionDuration; | ||
} | ||
declare module "shorter-js/src/strings/transitionDurationLegacy" { | ||
export default transitionDuration; | ||
/** | ||
* A global namespace for 'transitionDuration' string. | ||
* @type {string} | ||
*/ | ||
const transitionDuration: string; | ||
} | ||
declare module "shorter-js/src/strings/transitionDelay" { | ||
@@ -721,2 +761,10 @@ export default transitionDelay; | ||
} | ||
declare module "shorter-js/src/strings/transitionDelayLegacy" { | ||
export default transitionDelay; | ||
/** | ||
* A global namespace for 'transitionDelay' string. | ||
* @type {string} | ||
*/ | ||
const transitionDelay: string; | ||
} | ||
declare module "shorter-js/src/strings/transitionEndEvent" { | ||
@@ -730,2 +778,10 @@ export default transitionEndEvent; | ||
} | ||
declare module "shorter-js/src/strings/transitionEndEventLegacy" { | ||
export default transitionEndEvent; | ||
/** | ||
* A global namespace for 'transitionend' string. | ||
* @type {string} | ||
*/ | ||
const transitionEndEvent: string; | ||
} | ||
declare module "shorter-js/src/strings/transitionProperty" { | ||
@@ -739,2 +795,10 @@ export default transitionProperty; | ||
} | ||
declare module "shorter-js/src/strings/transitionPropertyLegacy" { | ||
export default transitionProperty; | ||
/** | ||
* A global namespace for 'transitionProperty' string. | ||
* @type {string} | ||
*/ | ||
const transitionProperty: string; | ||
} | ||
declare module "shorter-js/src/strings/addEventListener" { | ||
@@ -797,2 +861,10 @@ export default addEventListener; | ||
} | ||
declare module "shorter-js/src/strings/userAgentData" { | ||
export default userAgentData; | ||
/** | ||
* A global namespace for `userAgentData` event. | ||
* @type {string} | ||
*/ | ||
const userAgentData: string; | ||
} | ||
declare module "shorter-js/src/boolean/isMobile" { | ||
@@ -809,3 +881,3 @@ export default isMobile; | ||
/** | ||
* A global namespace for Apple browsers. | ||
* A global boolean for Apple browsers. | ||
* @type {boolean} | ||
@@ -818,3 +890,3 @@ */ | ||
/** | ||
* A global namespace for CSS3 3D transform support. | ||
* A global `boolean` for CSS3 3D transform support. | ||
* @type {boolean} | ||
@@ -824,2 +896,36 @@ */ | ||
} | ||
declare module "shorter-js/src/event/on" { | ||
/** | ||
* Add eventListener to an `HTMLElement` | `Document` target. | ||
* | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
export default function on(element: HTMLElement | Document, eventName: string, handler: EventListener, options: EventListenerOptions | boolean | undefined): void; | ||
} | ||
declare module "shorter-js/src/event/off" { | ||
/** | ||
* Remove eventListener from an `HTMLElement` | `Document` target. | ||
* | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
export default function off(element: HTMLElement | Document, eventName: string, handler: EventListener, options: EventListenerOptions | boolean | undefined): void; | ||
} | ||
declare module "shorter-js/src/event/one" { | ||
/** | ||
* Add an `eventListener` to an `HTMLElement` | `Document` target | ||
* and remove it once callback is called. | ||
* | ||
* @param {HTMLElement | Document} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | undefined} options other event options | ||
*/ | ||
export default function one(element: HTMLElement | Document, eventName: string, handler: EventListener, options: EventListenerOptions | boolean | undefined): void; | ||
} | ||
declare module "shorter-js/src/boolean/supportPassive" { | ||
@@ -852,3 +958,3 @@ export default supportPassive; | ||
/** | ||
* A global namespace for CSS3 animation support. | ||
* A global `boolean` for CSS3 animation support. | ||
* @type {boolean} | ||
@@ -894,64 +1000,31 @@ */ | ||
} | ||
declare module "shorter-js/src/event/on" { | ||
declare module "shorter-js/src/misc/isHTMLElement" { | ||
export default isHTMLElement; | ||
/** | ||
* Add eventListener to Element | ||
* Checks if an element is an `HTMLElement`. | ||
* | ||
* @param {Element} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
*/ | ||
export default function on(element: Element, eventName: string, handler: EventListener, options: EventListenerOptions | boolean | null): void; | ||
} | ||
declare module "shorter-js/src/event/off" { | ||
/** | ||
* Remove eventListener from Element | ||
* | ||
* @param {Element} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
*/ | ||
export default function off(element: Element, eventName: string, handler: EventListener, options: EventListenerOptions | boolean | null): void; | ||
} | ||
declare module "shorter-js/src/event/one" { | ||
/** | ||
* Add an eventListener to Element | ||
* and remove it once callback is called. | ||
* | ||
* @param {Element} element event.target | ||
* @param {string} eventName event.type | ||
* @param {EventListener} handler callback | ||
* @param {EventListenerOptions | boolean | null} options other event options | ||
*/ | ||
export default function one(element: Element, eventName: string, handler: EventListener, options: EventListenerOptions | boolean | null): void; | ||
} | ||
declare module "shorter-js/src/misc/isElement" { | ||
/** | ||
* Checks if an object is an `Element`. | ||
* | ||
* @param {any} element the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
export default function isElement(element: any): boolean; | ||
function isHTMLElement(element: any): boolean; | ||
} | ||
declare module "shorter-js/src/misc/querySelector" { | ||
/** | ||
* Utility to check if target is typeof `Element` | ||
* Utility to check if target is typeof `HTMLElement` | ||
* or find one that matches a selector. | ||
* | ||
* @param {Element | string} selector the input selector or target element | ||
* @param {Element=} parent optional Element to look into | ||
* @return {Element?} the Element or `querySelector` result | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {(ParentNode | HTMLElement)=} parent optional `HTMLElement` to look into | ||
* @return {HTMLElement?} the `HTMLElement` or `querySelector` result | ||
*/ | ||
export default function querySelector(selector: Element | string, parent?: Element | undefined): Element | null; | ||
export default function querySelector(selector: HTMLElement | string, parent?: (ParentNode | HTMLElement) | undefined): HTMLElement | null; | ||
} | ||
declare module "shorter-js/src/misc/data" { | ||
export function getInstance(element: Element | string, component: string): any; | ||
export function getInstance(target: HTMLElement | string, component: string): Record<string, any> | null; | ||
export default Data; | ||
namespace Data { | ||
function set(element: string | Element, component: string, instance: any): void; | ||
function set(target: string | HTMLElement, component: string, instance: any): void; | ||
function getAllFor(component: string): any; | ||
function get(element: string | Element, component: string): any; | ||
function remove(element: Element, component: string): void; | ||
function get(target: string | HTMLElement, component: string): any; | ||
function remove(target: string | HTMLElement, component: string): void; | ||
} | ||
@@ -962,7 +1035,21 @@ } | ||
namespace Timer { | ||
function set(target: string | Element, callback: any, delay: number, key?: string | undefined): void; | ||
function get(target: string | Element, key?: string | undefined): Map<Element, TimerHandler> | null; | ||
function clear(target: Element, key?: string | undefined): void; | ||
function set(target: string | HTMLElement, callback: any, delay: number, key?: string | undefined): void; | ||
function get(target: string | HTMLElement, key?: string | undefined): Map<Element, TimerHandler> | null; | ||
function clear(target: HTMLElement, key?: string | undefined): void; | ||
} | ||
} | ||
declare module "shorter-js/src/misc/getElementStyle" { | ||
/** | ||
* Shortcut for `window.getComputedStyle(element).propertyName` | ||
* static method. | ||
* | ||
* * If `element` parameter is not an `HTMLElement`, `getComputedStyle` | ||
* throws a `ReferenceError`. | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {string=} property the css property | ||
* @return {string} the css property value | ||
*/ | ||
export default function getElementStyle(element: HTMLElement, property?: string | undefined): string; | ||
} | ||
declare module "shorter-js/src/misc/getElementAnimationDelay" { | ||
@@ -973,6 +1060,6 @@ /** | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementAnimationDelay(element: Element): number; | ||
export default function getElementAnimationDelay(element: HTMLElement): number; | ||
} | ||
@@ -982,8 +1069,8 @@ declare module "shorter-js/src/misc/getElementAnimationDuration" { | ||
* Utility to get the computed `animationDuration` | ||
* from Element in miliseconds. | ||
* from `HTMLElement` in miliseconds. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementAnimationDuration(element: Element): number; | ||
export default function getElementAnimationDuration(element: HTMLElement): number; | ||
} | ||
@@ -995,7 +1082,37 @@ declare module "shorter-js/src/misc/emulateAnimationEnd" { | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `animationend` callback | ||
*/ | ||
export default function emulateAnimationEnd(element: Element, handler: EventListener): void; | ||
export default function emulateAnimationEnd(element: HTMLElement, handler: EventListener): void; | ||
} | ||
declare module "shorter-js/src/misc/getElementAnimationDelayLegacy" { | ||
/** | ||
* Utility to get the computed `animationDelay` | ||
* from Element in miliseconds. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementAnimationDelay(element: HTMLElement): number; | ||
} | ||
declare module "shorter-js/src/misc/getElementAnimationDurationLegacy" { | ||
/** | ||
* Utility to get the computed `animationDuration` | ||
* from `HTMLElement` in miliseconds. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementAnimationDuration(element: HTMLElement): number; | ||
} | ||
declare module "shorter-js/src/misc/emulateAnimationEndLegacy" { | ||
/** | ||
* Utility to make sure callbacks are consistently | ||
* called when animation ends. | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `animationend` callback | ||
*/ | ||
export default function emulateAnimationEnd(element: HTMLElement, handler: EventListener): void; | ||
} | ||
declare module "shorter-js/src/misc/getElementTransitionDelay" { | ||
@@ -1006,6 +1123,6 @@ /** | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementTransitionDelay(element: Element): number; | ||
export default function getElementTransitionDelay(element: HTMLElement): number; | ||
} | ||
@@ -1017,6 +1134,6 @@ declare module "shorter-js/src/misc/getElementTransitionDuration" { | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementTransitionDuration(element: Element): number; | ||
export default function getElementTransitionDuration(element: HTMLElement): number; | ||
} | ||
@@ -1028,28 +1145,59 @@ declare module "shorter-js/src/misc/emulateTransitionEnd" { | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `transitionend` callback | ||
*/ | ||
export default function emulateTransitionEnd(element: Element, handler: EventListener): void; | ||
export default function emulateTransitionEnd(element: HTMLElement, handler: EventListener): void; | ||
} | ||
declare module "shorter-js/src/misc/getElementTransitionDelayLegacy" { | ||
/** | ||
* Utility to get the computed `transitionDelay` | ||
* from Element in miliseconds. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementTransitionDelay(element: HTMLElement): number; | ||
} | ||
declare module "shorter-js/src/misc/getElementTransitionDurationLegacy" { | ||
/** | ||
* Utility to get the computed `transitionDuration` | ||
* from Element in miliseconds. | ||
* | ||
* @param {HTMLElement} element target | ||
* @return {number} the value in miliseconds | ||
*/ | ||
export default function getElementTransitionDuration(element: HTMLElement): number; | ||
} | ||
declare module "shorter-js/src/misc/emulateTransitionEndLegacy" { | ||
/** | ||
* Utility to make sure callbacks are consistently | ||
* called when transition ends. | ||
* | ||
* @param {HTMLElement} element target | ||
* @param {EventListener} handler `transitionend` callback | ||
*/ | ||
export default function emulateTransitionEnd(element: HTMLElement, handler: EventListener): void; | ||
} | ||
declare module "shorter-js/src/misc/isElementInScrollRange" { | ||
/** | ||
* Utility to determine if an `Element` | ||
* Utility to determine if an `HTMLElement` | ||
* is partially visible in viewport. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
*/ | ||
export default function isElementInScrollRange(element: Element): boolean; | ||
export default function isElementInScrollRange(element: HTMLElement): boolean; | ||
} | ||
declare module "shorter-js/src/misc/isElementInViewport" { | ||
/** | ||
* Utility to determine if an `Element` | ||
* Utility to determine if an `HTMLElement` | ||
* is fully visible in the viewport. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @return {boolean} Boolean | ||
*/ | ||
export default function isElementInViewport(element: Element): boolean; | ||
export default function isElementInViewport(element: HTMLElement): boolean; | ||
} | ||
declare module "shorter-js/src/misc/isMedia" { | ||
export default isMedia; | ||
/** | ||
@@ -1061,3 +1209,3 @@ * Checks if an element is an `<svg>`, `<img>` or `<video>`. | ||
*/ | ||
export default function isMedia(element: any): boolean; | ||
function isMedia(element: any): boolean; | ||
} | ||
@@ -1085,3 +1233,3 @@ declare module "shorter-js/src/misc/isRTL" { | ||
* | ||
* @typedef {string | Element | Function | number | boolean | null} niceValue | ||
* @typedef {string | HTMLElement | Function | number | boolean | null} niceValue | ||
*/ | ||
@@ -1098,3 +1246,3 @@ /** | ||
*/ | ||
export type niceValue = string | Element | Function | number | boolean | null; | ||
export type niceValue = string | HTMLElement | Function | number | boolean | null; | ||
} | ||
@@ -1114,3 +1262,3 @@ declare module "shorter-js/src/misc/ObjectKeys" { | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {Record<string, any>} defaultOps component default options | ||
@@ -1121,3 +1269,3 @@ * @param {Record<string, any>} inputOps component instance options | ||
*/ | ||
export default function normalizeOptions(element: Element, defaultOps: Record<string, any>, inputOps: Record<string, any>, ns?: string | undefined): Record<string, any>; | ||
export default function normalizeOptions(element: HTMLElement, defaultOps: Record<string, any>, inputOps: Record<string, any>, ns?: string | undefined): Record<string, any>; | ||
} | ||
@@ -1134,9 +1282,10 @@ declare module "shorter-js/src/misc/tryWrapper" { | ||
declare module "shorter-js/src/misc/reflow" { | ||
export default reflow; | ||
/** | ||
* Utility to force re-paint of an `Element` target. | ||
* Utility to force re-paint of an `HTMLElement` target. | ||
* | ||
* @param {Element | HTMLElement} element is the target | ||
* @param {HTMLElement} element is the target | ||
* @return {number} the `Element.offsetHeight` value | ||
*/ | ||
export default function reflow(element: Element | HTMLElement): number; | ||
function reflow(element: HTMLElement): number; | ||
} | ||
@@ -1149,5 +1298,5 @@ declare module "shorter-js/src/misc/ArrayFrom" { | ||
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object | ||
* @returns {Array} | ||
* @returns {Array<any>} | ||
*/ | ||
function ArrayFrom(arr: any[] | HTMLCollection | NodeList): any[]; | ||
function ArrayFrom(arr: any[] | HTMLCollection | NodeList): Array<any>; | ||
} | ||
@@ -1190,25 +1339,10 @@ declare module "shorter-js/src/misc/Float32ArrayFrom" { | ||
} | ||
declare module "shorter-js/src/misc/getElementStyle" { | ||
/** | ||
* Shortcut for `window.getComputedStyle(element).propertyName` | ||
* static method. | ||
* * If `element` parameter is not an `Element`, `getComputedStyle` | ||
* throws a `ReferenceError`. | ||
* * If no property is defined, the entire `CSSStyleDeclaration` | ||
* instance is returned. | ||
* | ||
* @param {Element} element target | ||
* @param {string=} property the css property | ||
* @return {string} the css property value | ||
*/ | ||
export default function getElementStyle(element: Element, property?: string | undefined): string; | ||
} | ||
declare module "shorter-js/src/misc/getAttribute" { | ||
export default getAttribute; | ||
/** | ||
* Shortcut for `Element.getAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.getAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
*/ | ||
function getAttribute(element: Element, attribute: string): string | null; | ||
function getAttribute(element: HTMLElement, attribute: string): string | null; | ||
} | ||
@@ -1218,8 +1352,8 @@ declare module "shorter-js/src/misc/setAttribute" { | ||
/** | ||
* Shortcut for `Element.setAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.setAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
* @param {string} value attribute value | ||
*/ | ||
function setAttribute(element: Element, attribute: string, value: string): void; | ||
function setAttribute(element: HTMLElement, attribute: string, value: string): void; | ||
} | ||
@@ -1229,16 +1363,16 @@ declare module "shorter-js/src/misc/removeAttribute" { | ||
/** | ||
* Shortcut for `Element.removeAttribute()` method. | ||
* @param {Element} element target element | ||
* Shortcut for `HTMLElement.removeAttribute()` method. | ||
* @param {HTMLElement} element target element | ||
* @param {string} attribute attribute name | ||
*/ | ||
function removeAttribute(element: Element, attribute: string): void; | ||
function removeAttribute(element: HTMLElement, attribute: string): void; | ||
} | ||
declare module "shorter-js/src/misc/isHTMLElement" { | ||
declare module "shorter-js/src/misc/setElementStyle" { | ||
export default setElementStyle; | ||
/** | ||
* Checks if an element is an `HTMLElement`. | ||
* | ||
* @param {any} element the target object | ||
* @returns {boolean} the query result | ||
* Shortcut for `HTMLElement.style.propertyName` method. | ||
* @param {HTMLElement} element target element | ||
* @param {Record<string, string>} styles attribute value | ||
*/ | ||
export default function isHTMLElement(element: any): boolean; | ||
function setElementStyle(element: HTMLElement, styles: Record<string, string>): Record<string, any>; | ||
} | ||
@@ -1255,3 +1389,24 @@ declare module "shorter-js/src/misc/isArray" { | ||
} | ||
declare module "shorter-js/src/misc/isString" { | ||
export default isString; | ||
/** | ||
* Shortcut for `typeof` static method. | ||
* | ||
* @param {any} str array-like iterable object | ||
* @returns {boolean} the query result | ||
*/ | ||
function isString(str: any): boolean; | ||
} | ||
declare module "shorter-js/src/misc/isElement" { | ||
export default isElement; | ||
/** | ||
* Checks if an object is an `Element`. | ||
* | ||
* @param {any} element the target object | ||
* @returns {boolean} the query result | ||
*/ | ||
function isElement(element: any): boolean; | ||
} | ||
declare module "shorter-js/src/misc/isNodeList" { | ||
export default isNodeList; | ||
/** | ||
@@ -1263,5 +1418,6 @@ * Checks if an object is a `NodeList`. | ||
*/ | ||
export default function isNodeList(object: any): boolean; | ||
function isNodeList(object: any): boolean; | ||
} | ||
declare module "shorter-js/src/misc/isHTMLCollection" { | ||
export default isHTMLCollection; | ||
/** | ||
@@ -1273,5 +1429,6 @@ * Checks if an object is an `HTMLCollection`. | ||
*/ | ||
export default function isHTMLCollection(object: any): boolean; | ||
function isHTMLCollection(object: any): boolean; | ||
} | ||
declare module "shorter-js/src/misc/isElementsArray" { | ||
export default isElementsArray; | ||
/** | ||
@@ -1283,7 +1440,7 @@ * Checks if an object is an `Array` in which all items are `Element`. | ||
*/ | ||
export default function isElementsArray(object: any): boolean; | ||
function isElementsArray(object: any): boolean; | ||
} | ||
declare module "shorter-js/src/misc/queryElement" { | ||
/** | ||
* Utility to check if target is typeof `Element` | ||
* Utility to check if target is typeof `HTMLElement` | ||
* or find one that matches a selector. | ||
@@ -1293,7 +1450,7 @@ * | ||
* | ||
* @param {Element | string} selector the input selector or target element | ||
* @param {Element=} parent optional Element to look into | ||
* @return {Element?} the Element or `querySelector` result | ||
* @param {HTMLElement | string} selector the input selector or target element | ||
* @param {(ParentNode | HTMLElement)=} parent optional `HTMLElement` to look into | ||
* @return {HTMLElement?} the Element or `querySelector` result | ||
*/ | ||
export default function queryElement(selector: Element | string, parent?: Element | undefined): Element | null; | ||
export default function queryElement(selector: HTMLElement | string, parent?: (ParentNode | HTMLElement) | undefined): HTMLElement | null; | ||
} | ||
@@ -1305,26 +1462,26 @@ declare module "shorter-js/src/misc/querySelectorAll" { | ||
* @param {string} selector the input selector | ||
* @param {ParentNode=} parent optional Element to look into | ||
* @return {NodeList} the query result | ||
* @param {(HTMLElement | ParentNode)=} parent optional Element to look into | ||
* @return {NodeListOf<HTMLElement>} the query result | ||
*/ | ||
export default function querySelectorAll(selector: string, parent?: ParentNode | undefined): NodeList; | ||
export default function querySelectorAll(selector: string, parent?: (HTMLElement | ParentNode) | undefined): NodeListOf<HTMLElement>; | ||
} | ||
declare module "shorter-js/src/misc/getElementsByTagName" { | ||
/** | ||
* Shortcut for `Element.getElementsByTagName` method. | ||
* Shortcut for `HTMLElement.getElementsByTagName` method. | ||
* | ||
* @param {string} selector the tag name | ||
* @param {Element=} parent optional Element to look into | ||
* @return {HTMLCollection} the 'HTMLCollection' | ||
* @param {HTMLElement=} parent optional Element to look into | ||
* @return {HTMLCollectionOf<Element | HTMLElement>} the 'HTMLCollection' | ||
*/ | ||
export default function getElementsByTagName(selector: string, parent?: Element | undefined): HTMLCollection; | ||
export default function getElementsByTagName(selector: string, parent?: HTMLElement | undefined): HTMLCollectionOf<Element | HTMLElement>; | ||
} | ||
declare module "shorter-js/src/misc/getElementsByClassName" { | ||
/** | ||
* Shortcut for `Element.getElementsByClassName` method. | ||
* Shortcut for `HTMLElement.getElementsByClassName` method. | ||
* | ||
* @param {string} selector the class name | ||
* @param {Element=} parent optional Element to look into | ||
* @return {HTMLCollection} the 'HTMLCollection' | ||
* @param {(HTMLElement)=} parent optional Element to look into | ||
* @return {HTMLCollectionOf<HTMLElement | Element>} the 'HTMLCollection' | ||
*/ | ||
export default function getElementsByClassName(selector: string, parent?: Element | undefined): HTMLCollection; | ||
export default function getElementsByClassName(selector: string, parent?: (HTMLElement) | undefined): HTMLCollectionOf<HTMLElement | Element>; | ||
} | ||
@@ -1424,9 +1581,17 @@ declare module "shorter-js/src/misc/version" { | ||
export { default as animationDuration } from "shorter-js/src/strings/animationDuration"; | ||
export { default as animationDurationLegacy } from "shorter-js/src/strings/animationDurationLegacy"; | ||
export { default as animationDelay } from "shorter-js/src/strings/animationDelay"; | ||
export { default as animationDelayLegacy } from "shorter-js/src/strings/animationDelayLegacy"; | ||
export { default as animationName } from "shorter-js/src/strings/animationName"; | ||
export { default as animationNameLegacy } from "shorter-js/src/strings/animationNameLegacy"; | ||
export { default as animationEndEvent } from "shorter-js/src/strings/animationEndEvent"; | ||
export { default as animationEndEventLegacy } from "shorter-js/src/strings/animationEndEventLegacy"; | ||
export { default as transitionDuration } from "shorter-js/src/strings/transitionDuration"; | ||
export { default as transitionDurationLegacy } from "shorter-js/src/strings/transitionDurationLegacy"; | ||
export { default as transitionDelay } from "shorter-js/src/strings/transitionDelay"; | ||
export { default as transitionDelayLegacy } from "shorter-js/src/strings/transitionDelayLegacy"; | ||
export { default as transitionEndEvent } from "shorter-js/src/strings/transitionEndEvent"; | ||
export { default as transitionEndEventLegacy } from "shorter-js/src/strings/transitionEndEventLegacy"; | ||
export { default as transitionProperty } from "shorter-js/src/strings/transitionProperty"; | ||
export { default as transitionPropertyLegacy } from "shorter-js/src/strings/transitionPropertyLegacy"; | ||
export { default as addEventListener } from "shorter-js/src/strings/addEventListener"; | ||
@@ -1456,3 +1621,5 @@ export { default as removeEventListener } from "shorter-js/src/strings/removeEventListener"; | ||
export { default as emulateAnimationEnd } from "shorter-js/src/misc/emulateAnimationEnd"; | ||
export { default as emulateAnimationEndLegacy } from "shorter-js/src/misc/emulateAnimationEndLegacy"; | ||
export { default as emulateTransitionEnd } from "shorter-js/src/misc/emulateTransitionEnd"; | ||
export { default as emulateTransitionEndLegacy } from "shorter-js/src/misc/emulateTransitionEndLegacy"; | ||
export { default as isElementInScrollRange } from "shorter-js/src/misc/isElementInScrollRange"; | ||
@@ -1464,5 +1631,9 @@ export { default as isElementInViewport } from "shorter-js/src/misc/isElementInViewport"; | ||
export { default as getElementAnimationDuration } from "shorter-js/src/misc/getElementAnimationDuration"; | ||
export { default as getElementAnimationDurationLegacy } from "shorter-js/src/misc/getElementAnimationDurationLegacy"; | ||
export { default as getElementAnimationDelay } from "shorter-js/src/misc/getElementAnimationDelay"; | ||
export { default as getElementAnimationDelayLegacy } from "shorter-js/src/misc/getElementAnimationDelayLegacy"; | ||
export { default as getElementTransitionDuration } from "shorter-js/src/misc/getElementTransitionDuration"; | ||
export { default as getElementTransitionDurationLegacy } from "shorter-js/src/misc/getElementTransitionDurationLegacy"; | ||
export { default as getElementTransitionDelay } from "shorter-js/src/misc/getElementTransitionDelay"; | ||
export { default as getElementTransitionDelayLegacy } from "shorter-js/src/misc/getElementTransitionDelayLegacy"; | ||
export { default as normalizeValue } from "shorter-js/src/misc/normalizeValue"; | ||
@@ -1478,10 +1649,12 @@ export { default as normalizeOptions } from "shorter-js/src/misc/normalizeOptions"; | ||
export { default as ObjectAssign } from "shorter-js/src/misc/ObjectAssign"; | ||
export { default as getElementStyle } from "shorter-js/src/misc/getElementStyle"; | ||
export { default as getAttribute } from "shorter-js/src/misc/getAttribute"; | ||
export { default as setAttribute } from "shorter-js/src/misc/setAttribute"; | ||
export { default as removeAttribute } from "shorter-js/src/misc/removeAttribute"; | ||
export { default as isHTMLElement } from "shorter-js/src/misc/isHTMLElement"; | ||
export { default as getElementStyle } from "shorter-js/src/misc/getElementStyle"; | ||
export { default as setElementStyle } from "shorter-js/src/misc/setElementStyle"; | ||
export { default as isArray } from "shorter-js/src/misc/isArray"; | ||
export { default as isString } from "shorter-js/src/misc/isString"; | ||
export { default as isElement } from "shorter-js/src/misc/isElement"; | ||
export { default as isNodeList } from "shorter-js/src/misc/isNodeList"; | ||
export { default as isHTMLElement } from "shorter-js/src/misc/isHTMLElement"; | ||
export { default as isHTMLCollection } from "shorter-js/src/misc/isHTMLCollection"; | ||
@@ -1488,0 +1661,0 @@ export { default as isElementsArray } from "shorter-js/src/misc/isElementsArray"; |
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
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
292158
180
7429
12