Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shorter-js

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shorter-js - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

src/misc/version.js

194

dist/shorter-js.esm.js
/*!
* shorter-js v0.2.1 (https://github.com/thednp/shorter-js)
* shorter-js v0.2.2 (https://github.com/thednp/shorter-js)
* Copyright 2019-2021 © dnp_theme

@@ -69,6 +69,14 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE)

const mobileBrands = /iPhone|iPad|iPod|Android/i;
const isMobile = navigator.userAgentData
? navigator.userAgentData.brands.some((x) => mobileBrands.test(x.brand))
: mobileBrands.test(navigator.userAgent);
const userAgentStr = 'userAgentData';
let isMobileCheck = false;
if (navigator[userAgentStr]) {
isMobileCheck = navigator[userAgentStr].brands.some((x) => mobileBrands.test(x.brand));
} else {
isMobileCheck = mobileBrands.test(navigator.userAgent);
}
const isMobile = isMobileCheck;
const support3DTransform = 'webkitPerspective' in document.head.style || 'perspective' in document.head.style;

@@ -97,8 +105,14 @@

const supportTouch = ('ontouchstart' in window || navigator.msMaxTouchPoints) || false;
const supportTouch = 'ontouchstart' in window || 'msMaxTouchPoints' in navigator;
var supportAnimation = 'webkitAnimation' in document.head.style || 'animation' in document.head.style;
const supportAnimation = 'webkitAnimation' in document.head.style || 'animation' in document.head.style;
const supportTransition = 'webkitTransition' in document.head.style || 'transition' in document.head.style;
/**
* Add class to Element.classList
*
* @param {Element} element target
* @param {string} classNAME to add
*/
function addClass(element, classNAME) {

@@ -108,2 +122,8 @@ element.classList.add(classNAME);

/**
* Remove class from Element.classList
*
* @param {Element} element target
* @param {string} classNAME to remove
*/
function removeClass(element, classNAME) {

@@ -113,2 +133,9 @@ element.classList.remove(classNAME);

/**
* Check class in Element.classList
*
* @param {Element} element target
* @param {string} classNAME to check
* @return {boolean}
*/
function hasClass(element, classNAME) {

@@ -118,24 +145,58 @@ return element.classList.contains(classNAME);

// attach handlers
function on(element, event, handler, options) {
/**
* Add eventListener to Element
*
* @param {Element} element target
* @param {string} eventName name
* @param {object | Function} handler callback
* @param {object | Boolean | undefined} options other event options
*/
function on(element, eventName, handler, options) {
const ops = options || false;
element.addEventListener(event, handler, ops);
element.addEventListener(eventName, handler, ops);
}
// detach handlers
function off(element, event, handler, options) {
/**
* Remove eventListener from Element
*
* @param {Element} element target
* @param {string} eventName name
* @param {object | Function} handler callback
* @param {object | Boolean | undefined} options other event options
*/
function off(element, eventName, handler, options) {
const ops = options || false;
element.removeEventListener(event, handler, ops);
element.removeEventListener(eventName, handler, ops);
}
// attach & detach handlers
function one(element, event, handler, options) {
on(element, event, function handlerWrapper(e) {
/**
* Add an eventListener to Element
* and remove it once callback is called.
*
* @param {Element} element target
* @param {string} eventName name of the event
* @param {object | Function} handler callback
* @param {object | 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, event, handlerWrapper, options);
off(element, eventName, handlerWrapper, options);
}
}, options);
}
on(element, eventName, handlerWrapper, options);
}
/**
* Utility to get the computed animationDuration
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
function getElementAnimationDuration(element) {

@@ -152,2 +213,9 @@ const computedStyle = getComputedStyle(element);

/**
* Utility to make sure callbacks are consistently
* called when animation ends.
*
* @param {Element} element target
* @param {Function} handler callback
*/
function emulateAnimationEnd(element, handler) {

@@ -174,2 +242,9 @@ let called = 0;

/**
* Utility to get the computed transitionDuration
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
function getElementTransitionDuration(element) {

@@ -186,2 +261,9 @@ const computedStyle = getComputedStyle(element);

/**
* Utility to make sure callbacks are consistently
* called when transition ends.
*
* @param {Element} element target
* @param {Function} handler callback
*/
function emulateTransitionEnd(element, handler) {

@@ -208,2 +290,9 @@ let called = 0;

/**
* Utility to determine if an Element
* is partially visible in viewport.
*
* @param {Element} element target
* @return {Boolean}
*/
function isElementInScrollRange(element) {

@@ -215,3 +304,9 @@ const bcr = element.getBoundingClientRect();

// check if element is in viewport
/**
* Utility to determine if an Element
* is fully visible in the viewport.
*
* @param {Element} element target
* @return {Boolean}
*/
function isElementInViewport(element) {

@@ -229,4 +324,11 @@ const bcr = element.getBoundingClientRect();

var passiveHandler = supportPassive ? { passive: true } : false;
const passiveHandler = supportPassive ? { passive: true } : false;
/**
* Utility to get the computed animationDelay
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
function getElementAnimationDelay(element) {

@@ -243,2 +345,9 @@ const computedStyle = getComputedStyle(element);

/**
* Utility to get the computed transitionDelay
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
function getElementTransitionDelay(element) {

@@ -255,2 +364,10 @@ const computedStyle = getComputedStyle(element);

/**
* Utility to check if target is typeof Element
* or find one that matches a selector.
*
* @param {string | Element} selector the input selector or target element
* @param {undefined | Element} parent optional Element to look into
* @return {null | Element} the Element
*/
function queryElement(selector, parent) {

@@ -261,2 +378,8 @@ const lookUp = parent && parent instanceof Element ? parent : document;

/**
* Utility to normalize component options
*
* @param {string | Function | Element | object} value the input value
* @return {string | Function | Element | object} the normalized value
*/
function normalizeValue(value) {

@@ -283,5 +406,15 @@ if (value === 'true') {

/**
* Utility to normalize component options
*
* @param {Element} element target
* @param {object} defaultOps component default options
* @param {object} inputOps component instance options
* @param {string} ns component namespace
* @return {object} normalized component options object
*/
function normalizeOptions(element, defaultOps, inputOps, ns) {
const normalOps = {};
const dataOps = {};
// @ts-ignore
const data = { ...element.dataset };

@@ -317,2 +450,9 @@

/**
* Utility to wrap a callback
* in a try() catch(e)
*
* @param {Function} fn callback
* @param {string} origin callback context description
*/
function tryWrapper(fn, origin) {

@@ -324,9 +464,20 @@ try { fn(); } catch (e) {

/**
* Utility to force re-paint of an Element
*
* @param {Element} element is the target
* @return {Number} the Element.offsetHeight value
*/
function reflow(element) {
// @ts-ignore
return element.offsetHeight;
}
var version = "0.2.2";
// @ts-ignore
// strings FIRST
var index = {
const SHORTER = {
mouseClickEvents,

@@ -375,4 +526,5 @@ mouseHoverEvents,

reflow,
Version: version,
};
export default index;
export default SHORTER;

4

dist/shorter-js.esm.min.js

@@ -1,2 +0,2 @@

// shorter-js v0.2.1 | dnp_theme © 2021 | MIT-License
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",s="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i,m=navigator.userAgentData?navigator.userAgentData.brands.some(e=>c.test(e.brand)):c.test(navigator.userAgent),d="webkitPerspective"in document.head.style||"perspective"in document.head.style,l=(()=>{let e=!1;try{const n=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}catch(e){throw Error("Passive events are not supported")}return e})(),b="webkitTransform"in document.head.style||"transform"in document.head.style,p="ontouchstart"in window||navigator.msMaxTouchPoints||!1;var g="webkitAnimation"in document.head.style||"animation"in document.head.style;const v="webkitTransition"in document.head.style||"transition"in document.head.style;function E(e,n,t,i){const o=i||!1;e.addEventListener(n,t,o)}function y(e,n,t,i){const o=i||!1;e.removeEventListener(n,t,o)}function f(e){const t=getComputedStyle(e),i=t[o],a=t[n],s=a.includes("ms")?1:1e3,r=g&&i&&"none"!==i?parseFloat(a)*s:0;return Number.isNaN(r)?0:r}function h(e){const n=getComputedStyle(e),t=n[s],i=n[a],o=i.includes("ms")?1:1e3,r=v&&t&&"none"!==t?parseFloat(i)*o:0;return Number.isNaN(r)?0:r}function w(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}var k={mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},focusEvents:{in:"focusin",out:"focusout"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},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:n,animationDelay:t,animationName:o,animationEndEvent:i,transitionDuration:a,transitionDelay:r,transitionEndEvent:u,transitionProperty:s,isMobile:m,support3DTransform:d,supportPassive:l,supportTransform:b,supportTouch:p,supportAnimation:g,supportTransition:v,addEventListener:"addEventListener",removeEventListener:"removeEventListener",addClass:function(e,n){e.classList.add(n)},removeClass:function(e,n){e.classList.remove(n)},hasClass:function(e,n){return e.classList.contains(n)},on:E,off:y,one:function(e,n,t,i){E(e,n,(function o(a){a.target===e&&(t.apply(e,[a]),y(e,n,o,i))}),i)},emulateAnimationEnd:function(e,n){let t=0;const o=new Event(i),a=f(e);a?(e.addEventListener(i,(function o(a){a.target===e&&(n.apply(e,[a]),e.removeEventListener(i,o),t=1)})),setTimeout(()=>{t||e.dispatchEvent(o)},a+17)):n.apply(e,[o])},emulateTransitionEnd:function(e,n){let t=0;const i=new Event(u),o=h(e);o?(e.addEventListener(u,(function i(o){o.target===e&&(n.apply(e,[o]),e.removeEventListener(u,i),t=1)})),setTimeout(()=>{t||e.dispatchEvent(i)},o+17)):n.apply(e,[i])},isElementInScrollRange:function(e){const n=e.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight;return n.top<=t&&n.bottom>=0},isElementInViewport:function(e){const n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&n.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!l&&{passive:!0},getElementAnimationDuration:f,getElementAnimationDelay:function(e){const n=getComputedStyle(e),i=n[o],a=n[t],s=a.includes("ms")?1:1e3,r=g&&i&&"none"!==i?parseFloat(a)*s:0;return Number.isNaN(r)?0:r},getElementTransitionDuration:h,getElementTransitionDelay:function(e){const n=getComputedStyle(e),t=n[s],i=n[r],o=i.includes("ms")?1:1e3,a=v&&t&&"none"!==t?parseFloat(i)*o:0;return Number.isNaN(a)?0:a},queryElement:function(e,n){const t=n&&n instanceof Element?n:document;return e instanceof Element?e:t.querySelector(e)},normalizeValue:w,normalizeOptions:function(e,n,t,i){const o={},a={},s={...e.dataset};return Object.keys(s).forEach(e=>{const n=e.includes(i)?e.replace(i,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;a[n]=w(s[e])}),Object.keys(t).forEach(e=>{t[e]=w(t[e])}),Object.keys(n).forEach(e=>{o[e]=e in t?t[e]:e in a?a[e]:n[e]}),o},tryWrapper:function(e,n){try{e()}catch(e){throw TypeError(`${n} ${e}`)}},reflow:function(e){return e.offsetHeight}};export default k;
// shorter-js v0.2.2 | dnp_theme © 2021 | MIT-License
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",s="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i;let m=!1;m=navigator.userAgentData?navigator.userAgentData.brands.some(e=>c.test(e.brand)):c.test(navigator.userAgent);const d=m,l="webkitPerspective"in document.head.style||"perspective"in document.head.style,b=(()=>{let e=!1;try{const n=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}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,v="webkitAnimation"in document.head.style||"animation"in document.head.style,E="webkitTransition"in document.head.style||"transition"in document.head.style;function y(e,n,t,i){const o=i||!1;e.addEventListener(n,t,o)}function f(e,n,t,i){const o=i||!1;e.removeEventListener(n,t,o)}function h(e){const t=getComputedStyle(e),i=t[o],a=t[n],s=a.includes("ms")?1:1e3,r=v&&i&&"none"!==i?parseFloat(a)*s:0;return Number.isNaN(r)?0:r}function w(e){const n=getComputedStyle(e),t=n[s],i=n[a],o=i.includes("ms")?1:1e3,r=E&&t&&"none"!==t?parseFloat(i)*o:0;return Number.isNaN(r)?0:r}function k(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const z={mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},focusEvents:{in:"focusin",out:"focusout"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},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:n,animationDelay:t,animationName:o,animationEndEvent:i,transitionDuration:a,transitionDelay:r,transitionEndEvent:u,transitionProperty:s,isMobile:d,support3DTransform:l,supportPassive:b,supportTransform:p,supportTouch:g,supportAnimation:v,supportTransition:E,addEventListener:"addEventListener",removeEventListener:"removeEventListener",addClass:function(e,n){e.classList.add(n)},removeClass:function(e,n){e.classList.remove(n)},hasClass:function(e,n){return e.classList.contains(n)},on:y,off:f,one:function(e,n,t,i){y(e,n,(function o(a){a.target===e&&(t.apply(e,[a]),f(e,n,o,i))}),i)},emulateAnimationEnd:function(e,n){let t=0;const o=new Event(i),a=h(e);a?(e.addEventListener(i,(function o(a){a.target===e&&(n.apply(e,[a]),e.removeEventListener(i,o),t=1)})),setTimeout(()=>{t||e.dispatchEvent(o)},a+17)):n.apply(e,[o])},emulateTransitionEnd:function(e,n){let t=0;const i=new Event(u),o=w(e);o?(e.addEventListener(u,(function i(o){o.target===e&&(n.apply(e,[o]),e.removeEventListener(u,i),t=1)})),setTimeout(()=>{t||e.dispatchEvent(i)},o+17)):n.apply(e,[i])},isElementInScrollRange:function(e){const n=e.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight;return n.top<=t&&n.bottom>=0},isElementInViewport:function(e){const n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&n.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!b&&{passive:!0},getElementAnimationDuration:h,getElementAnimationDelay:function(e){const n=getComputedStyle(e),i=n[o],a=n[t],s=a.includes("ms")?1:1e3,r=v&&i&&"none"!==i?parseFloat(a)*s:0;return Number.isNaN(r)?0:r},getElementTransitionDuration:w,getElementTransitionDelay:function(e){const n=getComputedStyle(e),t=n[s],i=n[r],o=i.includes("ms")?1:1e3,a=E&&t&&"none"!==t?parseFloat(i)*o:0;return Number.isNaN(a)?0:a},queryElement:function(e,n){const t=n&&n instanceof Element?n:document;return e instanceof Element?e:t.querySelector(e)},normalizeValue:k,normalizeOptions:function(e,n,t,i){const o={},a={},s={...e.dataset};return Object.keys(s).forEach(e=>{const n=e.includes(i)?e.replace(i,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;a[n]=k(s[e])}),Object.keys(t).forEach(e=>{t[e]=k(t[e])}),Object.keys(n).forEach(e=>{o[e]=e in t?t[e]:e in a?a[e]:n[e]}),o},tryWrapper:function(e,n){try{e()}catch(e){throw TypeError(`${n} ${e}`)}},reflow:function(e){return e.offsetHeight},Version:"0.2.2"};export default z;
/*!
* shorter-js v0.2.1 (https://github.com/thednp/shorter-js)
* shorter-js v0.2.2 (https://github.com/thednp/shorter-js)
* Copyright 2019-2021 © dnp_theme

@@ -75,6 +75,14 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE)

var mobileBrands = /iPhone|iPad|iPod|Android/i;
var isMobile = navigator.userAgentData
? navigator.userAgentData.brands.some(function (x) { return mobileBrands.test(x.brand); })
: mobileBrands.test(navigator.userAgent);
var userAgentStr = 'userAgentData';
var isMobileCheck = false;
if (navigator[userAgentStr]) {
isMobileCheck = navigator[userAgentStr].brands.some(function (x) { return mobileBrands.test(x.brand); });
} else {
isMobileCheck = mobileBrands.test(navigator.userAgent);
}
var isMobile = isMobileCheck;
var support3DTransform = 'webkitPerspective' in document.head.style || 'perspective' in document.head.style;

@@ -103,3 +111,3 @@

var supportTouch = ('ontouchstart' in window || navigator.msMaxTouchPoints) || false;
var supportTouch = 'ontouchstart' in window || 'msMaxTouchPoints' in navigator;

@@ -110,2 +118,8 @@ var supportAnimation = 'webkitAnimation' in document.head.style || 'animation' in document.head.style;

/**
* Add class to Element.classList
*
* @param {Element} element target
* @param {string} classNAME to add
*/
function addClass(element, classNAME) {

@@ -115,2 +129,8 @@ element.classList.add(classNAME);

/**
* Remove class from Element.classList
*
* @param {Element} element target
* @param {string} classNAME to remove
*/
function removeClass(element, classNAME) {

@@ -120,2 +140,9 @@ element.classList.remove(classNAME);

/**
* Check class in Element.classList
*
* @param {Element} element target
* @param {string} classNAME to check
* @return {boolean}
*/
function hasClass(element, classNAME) {

@@ -125,24 +152,58 @@ return element.classList.contains(classNAME);

// attach handlers
function on(element, event, handler, options) {
/**
* Add eventListener to Element
*
* @param {Element} element target
* @param {string} eventName name
* @param {object | Function} handler callback
* @param {object | Boolean | undefined} options other event options
*/
function on(element, eventName, handler, options) {
var ops = options || false;
element.addEventListener(event, handler, ops);
element.addEventListener(eventName, handler, ops);
}
// detach handlers
function off(element, event, handler, options) {
/**
* Remove eventListener from Element
*
* @param {Element} element target
* @param {string} eventName name
* @param {object | Function} handler callback
* @param {object | Boolean | undefined} options other event options
*/
function off(element, eventName, handler, options) {
var ops = options || false;
element.removeEventListener(event, handler, ops);
element.removeEventListener(eventName, handler, ops);
}
// attach & detach handlers
function one(element, event, handler, options) {
on(element, event, function handlerWrapper(e) {
/**
* Add an eventListener to Element
* and remove it once callback is called.
*
* @param {Element} element target
* @param {string} eventName name of the event
* @param {object | Function} handler callback
* @param {object | 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, event, handlerWrapper, options);
off(element, eventName, handlerWrapper, options);
}
}, options);
}
on(element, eventName, handlerWrapper, options);
}
/**
* Utility to get the computed animationDuration
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
function getElementAnimationDuration(element) {

@@ -159,2 +220,9 @@ var computedStyle = getComputedStyle(element);

/**
* Utility to make sure callbacks are consistently
* called when animation ends.
*
* @param {Element} element target
* @param {Function} handler callback
*/
function emulateAnimationEnd(element, handler) {

@@ -181,2 +249,9 @@ var called = 0;

/**
* Utility to get the computed transitionDuration
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
function getElementTransitionDuration(element) {

@@ -193,2 +268,9 @@ var computedStyle = getComputedStyle(element);

/**
* Utility to make sure callbacks are consistently
* called when transition ends.
*
* @param {Element} element target
* @param {Function} handler callback
*/
function emulateTransitionEnd(element, handler) {

@@ -215,2 +297,9 @@ var called = 0;

/**
* Utility to determine if an Element
* is partially visible in viewport.
*
* @param {Element} element target
* @return {Boolean}
*/
function isElementInScrollRange(element) {

@@ -222,3 +311,9 @@ var bcr = element.getBoundingClientRect();

// check if element is in viewport
/**
* Utility to determine if an Element
* is fully visible in the viewport.
*
* @param {Element} element target
* @return {Boolean}
*/
function isElementInViewport(element) {

@@ -238,2 +333,9 @@ var bcr = element.getBoundingClientRect();

/**
* Utility to get the computed animationDelay
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
function getElementAnimationDelay(element) {

@@ -250,2 +352,9 @@ var computedStyle = getComputedStyle(element);

/**
* Utility to get the computed transitionDelay
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
function getElementTransitionDelay(element) {

@@ -262,2 +371,10 @@ var computedStyle = getComputedStyle(element);

/**
* Utility to check if target is typeof Element
* or find one that matches a selector.
*
* @param {string | Element} selector the input selector or target element
* @param {undefined | Element} parent optional Element to look into
* @return {null | Element} the Element
*/
function queryElement(selector, parent) {

@@ -268,2 +385,8 @@ var lookUp = parent && parent instanceof Element ? parent : document;

/**
* Utility to normalize component options
*
* @param {string | Function | Element | object} value the input value
* @return {string | Function | Element | object} the normalized value
*/
function normalizeValue(value) {

@@ -290,5 +413,15 @@ if (value === 'true') {

/**
* Utility to normalize component options
*
* @param {Element} element target
* @param {object} defaultOps component default options
* @param {object} inputOps component instance options
* @param {string} ns component namespace
* @return {object} normalized component options object
*/
function normalizeOptions(element, defaultOps, inputOps, ns) {
var normalOps = {};
var dataOps = {};
// @ts-ignore
var data = Object.assign({}, element.dataset);

@@ -324,2 +457,9 @@

/**
* Utility to wrap a callback
* in a try() catch(e)
*
* @param {Function} fn callback
* @param {string} origin callback context description
*/
function tryWrapper(fn, origin) {

@@ -331,9 +471,20 @@ try { fn(); } catch (e) {

/**
* Utility to force re-paint of an Element
*
* @param {Element} element is the target
* @return {Number} the Element.offsetHeight value
*/
function reflow(element) {
// @ts-ignore
return element.offsetHeight;
}
var version = "0.2.2";
// @ts-ignore
// strings FIRST
var index = {
var SHORTER = {
mouseClickEvents: mouseClickEvents,

@@ -382,6 +533,7 @@ mouseHoverEvents: mouseHoverEvents,

reflow: reflow,
Version: version,
};
return index;
return SHORTER;
})));

@@ -1,2 +0,2 @@

// shorter-js v0.2.1 | dnp_theme © 2021 | MIT-License
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).SHORTER=n()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",u="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i,d=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return c.test(e.brand)})):c.test(navigator.userAgent),m="webkitPerspective"in document.head.style||"perspective"in document.head.style,l=function(){var e=!1;try{var n=Object.defineProperty({},"passive",{get:function(){return e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}catch(e){throw Error("Passive events are not supported")}return e}(),b="webkitTransform"in document.head.style||"transform"in document.head.style,v="ontouchstart"in window||navigator.msMaxTouchPoints||!1,p="webkitAnimation"in document.head.style||"animation"in document.head.style,f="webkitTransition"in document.head.style||"transition"in document.head.style;function g(e,n,t,i){var o=i||!1;e.addEventListener(n,t,o)}function E(e,n,t,i){var o=i||!1;e.removeEventListener(n,t,o)}function y(e){var t=getComputedStyle(e),i=t[o],a=t[n],r=a.includes("ms")?1:1e3,u=p&&i&&"none"!==i?parseFloat(a)*r:0;return Number.isNaN(u)?0:u}function h(e){var n=getComputedStyle(e),t=n[r],i=n[a],o=i.includes("ms")?1:1e3,u=f&&t&&"none"!==t?parseFloat(i)*o:0;return Number.isNaN(u)?0:u}function w(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}return{mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},focusEvents:{in:"focusin",out:"focusout"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},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:n,animationDelay:t,animationName:o,animationEndEvent:i,transitionDuration:a,transitionDelay:u,transitionEndEvent:s,transitionProperty:r,isMobile:d,support3DTransform:m,supportPassive:l,supportTransform:b,supportTouch:v,supportAnimation:p,supportTransition:f,addEventListener:"addEventListener",removeEventListener:"removeEventListener",addClass:function(e,n){e.classList.add(n)},removeClass:function(e,n){e.classList.remove(n)},hasClass:function(e,n){return e.classList.contains(n)},on:g,off:E,one:function(e,n,t,i){g(e,n,(function o(a){a.target===e&&(t.apply(e,[a]),E(e,n,o,i))}),i)},emulateAnimationEnd:function(e,n){var t=0,o=new Event(i),a=y(e);a?(e.addEventListener(i,(function o(a){a.target===e&&(n.apply(e,[a]),e.removeEventListener(i,o),t=1)})),setTimeout((function(){t||e.dispatchEvent(o)}),a+17)):n.apply(e,[o])},emulateTransitionEnd:function(e,n){var t=0,i=new Event(s),o=h(e);o?(e.addEventListener(s,(function i(o){o.target===e&&(n.apply(e,[o]),e.removeEventListener(s,i),t=1)})),setTimeout((function(){t||e.dispatchEvent(i)}),o+17)):n.apply(e,[i])},isElementInScrollRange:function(e){var n=e.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight;return n.top<=t&&n.bottom>=0},isElementInViewport:function(e){var n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&n.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!l&&{passive:!0},getElementAnimationDuration:y,getElementAnimationDelay:function(e){var n=getComputedStyle(e),i=n[o],a=n[t],r=a.includes("ms")?1:1e3,u=p&&i&&"none"!==i?parseFloat(a)*r:0;return Number.isNaN(u)?0:u},getElementTransitionDuration:h,getElementTransitionDelay:function(e){var n=getComputedStyle(e),t=n[r],i=n[u],o=i.includes("ms")?1:1e3,a=f&&t&&"none"!==t?parseFloat(i)*o:0;return Number.isNaN(a)?0:a},queryElement:function(e,n){var t=n&&n instanceof Element?n:document;return e instanceof Element?e:t.querySelector(e)},normalizeValue:w,normalizeOptions:function(e,n,t,i){var o={},a={},r=Object.assign({},e.dataset);return Object.keys(r).forEach((function(e){var n=e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[n]=w(r[e])})),Object.keys(t).forEach((function(e){t[e]=w(t[e])})),Object.keys(n).forEach((function(e){o[e]=e in t?t[e]:e in a?a[e]:n[e]})),o},tryWrapper:function(e,n){try{e()}catch(e){throw TypeError(n+" "+e)}},reflow:function(e){return e.offsetHeight}}}));
// shorter-js v0.2.2 | dnp_theme © 2021 | MIT-License
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).SHORTER=n()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",u="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i,d=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return c.test(e.brand)})):c.test(navigator.userAgent),m="webkitPerspective"in document.head.style||"perspective"in document.head.style,l=function(){var e=!1;try{var n=Object.defineProperty({},"passive",{get:function(){return e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}catch(e){throw Error("Passive events are not supported")}return e}(),b="webkitTransform"in document.head.style||"transform"in document.head.style,v="ontouchstart"in window||"msMaxTouchPoints"in navigator,p="webkitAnimation"in document.head.style||"animation"in document.head.style,f="webkitTransition"in document.head.style||"transition"in document.head.style;function g(e,n,t,i){var o=i||!1;e.addEventListener(n,t,o)}function E(e,n,t,i){var o=i||!1;e.removeEventListener(n,t,o)}function y(e){var t=getComputedStyle(e),i=t[o],a=t[n],r=a.includes("ms")?1:1e3,u=p&&i&&"none"!==i?parseFloat(a)*r:0;return Number.isNaN(u)?0:u}function h(e){var n=getComputedStyle(e),t=n[r],i=n[a],o=i.includes("ms")?1:1e3,u=f&&t&&"none"!==t?parseFloat(i)*o:0;return Number.isNaN(u)?0:u}function w(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}return{mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},focusEvents:{in:"focusin",out:"focusout"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},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:n,animationDelay:t,animationName:o,animationEndEvent:i,transitionDuration:a,transitionDelay:u,transitionEndEvent:s,transitionProperty:r,isMobile:d,support3DTransform:m,supportPassive:l,supportTransform:b,supportTouch:v,supportAnimation:p,supportTransition:f,addEventListener:"addEventListener",removeEventListener:"removeEventListener",addClass:function(e,n){e.classList.add(n)},removeClass:function(e,n){e.classList.remove(n)},hasClass:function(e,n){return e.classList.contains(n)},on:g,off:E,one:function(e,n,t,i){g(e,n,(function o(a){a.target===e&&(t.apply(e,[a]),E(e,n,o,i))}),i)},emulateAnimationEnd:function(e,n){var t=0,o=new Event(i),a=y(e);a?(e.addEventListener(i,(function o(a){a.target===e&&(n.apply(e,[a]),e.removeEventListener(i,o),t=1)})),setTimeout((function(){t||e.dispatchEvent(o)}),a+17)):n.apply(e,[o])},emulateTransitionEnd:function(e,n){var t=0,i=new Event(s),o=h(e);o?(e.addEventListener(s,(function i(o){o.target===e&&(n.apply(e,[o]),e.removeEventListener(s,i),t=1)})),setTimeout((function(){t||e.dispatchEvent(i)}),o+17)):n.apply(e,[i])},isElementInScrollRange:function(e){var n=e.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight;return n.top<=t&&n.bottom>=0},isElementInViewport:function(e){var n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&n.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!l&&{passive:!0},getElementAnimationDuration:y,getElementAnimationDelay:function(e){var n=getComputedStyle(e),i=n[o],a=n[t],r=a.includes("ms")?1:1e3,u=p&&i&&"none"!==i?parseFloat(a)*r:0;return Number.isNaN(u)?0:u},getElementTransitionDuration:h,getElementTransitionDelay:function(e){var n=getComputedStyle(e),t=n[r],i=n[u],o=i.includes("ms")?1:1e3,a=f&&t&&"none"!==t?parseFloat(i)*o:0;return Number.isNaN(a)?0:a},queryElement:function(e,n){var t=n&&n instanceof Element?n:document;return e instanceof Element?e:t.querySelector(e)},normalizeValue:w,normalizeOptions:function(e,n,t,i){var o={},a={},r=Object.assign({},e.dataset);return Object.keys(r).forEach((function(e){var n=e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[n]=w(r[e])})),Object.keys(t).forEach((function(e){t[e]=w(t[e])})),Object.keys(n).forEach((function(e){o[e]=e in t?t[e]:e in a?a[e]:n[e]})),o},tryWrapper:function(e,n){try{e()}catch(e){throw TypeError(n+" "+e)}},reflow:function(e){return e.offsetHeight},Version:"0.2.2"}}));
{
"name": "shorter-js",
"version": "0.2.1",
"version": "0.2.2",
"description": "A small ES6+ library with various JavaScript tools useful for creating light libraries.",

@@ -8,5 +8,8 @@ "main": "dist/shorter-js.min.js",

"jsnext": "src/index.js",
"types": "types/index.d.ts",
"files": [
"dist/*.{js,map}",
"src/**/*.{js,map}"
"src/**/*.{js,map}",
"types/**/*.{ts,map}",
"types/*.{ts,map}"
],

@@ -17,2 +20,3 @@ "scripts": {

"lint:js": "eslint src/ --config .eslintrc",
"build-ts": "tsc -d",
"build": "npm run lint:js && npm run umd && npm run umdmin && npm run esm && npm run esmmin",

@@ -48,4 +52,5 @@ "umd": "rollup --environment FORMAT:umd,MIN:false -c",

"rollup": "^1.31.1",
"rollup-plugin-terser": "^5.2.0"
"rollup-plugin-terser": "^5.2.0",
"typescript": "^4.4.4"
}
}

@@ -0,0 +0,0 @@ # shorter-js

const mobileBrands = /iPhone|iPad|iPod|Android/i;
const isMobile = navigator.userAgentData
? navigator.userAgentData.brands.some((x) => mobileBrands.test(x.brand))
: mobileBrands.test(navigator.userAgent);
const userAgentStr = 'userAgentData';
let isMobileCheck = false;
if (navigator[userAgentStr]) {
isMobileCheck = navigator[userAgentStr].brands.some((x) => mobileBrands.test(x.brand));
} else {
isMobileCheck = mobileBrands.test(navigator.userAgent);
}
const isMobile = isMobileCheck;
export default isMobile;

@@ -1,1 +0,2 @@

export default 'webkitAnimation' in document.head.style || 'animation' in document.head.style;
const supportAnimation = 'webkitAnimation' in document.head.style || 'animation' in document.head.style;
export default supportAnimation;

@@ -1,2 +0,2 @@

const supportTouch = ('ontouchstart' in window || navigator.msMaxTouchPoints) || false;
const supportTouch = 'ontouchstart' in window || 'msMaxTouchPoints' in navigator;
export default supportTouch;

@@ -0,3 +1,9 @@

/**
* Add class to Element.classList
*
* @param {Element} element target
* @param {string} classNAME to add
*/
export default function addClass(element, classNAME) {
element.classList.add(classNAME);
}

@@ -0,3 +1,10 @@

/**
* Check class in Element.classList
*
* @param {Element} element target
* @param {string} classNAME to check
* @return {boolean}
*/
export default function hasClass(element, classNAME) {
return element.classList.contains(classNAME);
}

@@ -0,3 +1,9 @@

/**
* Remove class from Element.classList
*
* @param {Element} element target
* @param {string} classNAME to remove
*/
export default function removeClass(element, classNAME) {
element.classList.remove(classNAME);
}

@@ -1,5 +0,12 @@

// detach handlers
export default function off(element, event, handler, options) {
/**
* Remove eventListener from Element
*
* @param {Element} element target
* @param {string} eventName name
* @param {object | Function} handler callback
* @param {object | Boolean | undefined} options other event options
*/
export default function off(element, eventName, handler, options) {
const ops = options || false;
element.removeEventListener(event, handler, ops);
element.removeEventListener(eventName, handler, ops);
}

@@ -1,5 +0,12 @@

// attach handlers
export default function on(element, event, handler, options) {
/**
* Add eventListener to Element
*
* @param {Element} element target
* @param {string} eventName name
* @param {object | Function} handler callback
* @param {object | Boolean | undefined} options other event options
*/
export default function on(element, eventName, handler, options) {
const ops = options || false;
element.addEventListener(event, handler, ops);
element.addEventListener(eventName, handler, ops);
}
import on from './on.js';
import off from './off.js';
// attach & detach handlers
export default function one(element, event, handler, options) {
on(element, event, function handlerWrapper(e) {
/**
* Add an eventListener to Element
* and remove it once callback is called.
*
* @param {Element} element target
* @param {string} eventName name of the event
* @param {object | Function} handler callback
* @param {object | Boolean | undefined} options other event options
*/
export default 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, event, handlerWrapper, options);
off(element, eventName, handlerWrapper, options);
}
}, options);
}
on(element, eventName, handlerWrapper, options);
}

@@ -54,3 +54,5 @@ // strings FIRST

export default {
import Version from './misc/version.js';
const SHORTER = {
mouseClickEvents,

@@ -99,2 +101,5 @@ mouseHoverEvents,

reflow,
Version,
};
export default SHORTER;
import animationEndEvent from '../strings/animationEndEvent.js';
import getElementAnimationDuration from './getElementAnimationDuration.js';
/**
* Utility to make sure callbacks are consistently
* called when animation ends.
*
* @param {Element} element target
* @param {Function} handler callback
*/
export default function emulateAnimationEnd(element, handler) {

@@ -5,0 +12,0 @@ let called = 0;

import transitionEndEvent from '../strings/transitionEndEvent.js';
import getElementTransitionDuration from './getElementTransitionDuration.js';
/**
* Utility to make sure callbacks are consistently
* called when transition ends.
*
* @param {Element} element target
* @param {Function} handler callback
*/
export default function emulateTransitionEnd(element, handler) {

@@ -5,0 +12,0 @@ let called = 0;

@@ -5,2 +5,9 @@ import supportAnimation from '../boolean/supportAnimation.js';

/**
* Utility to get the computed animationDelay
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
export default function getElementAnimationDelay(element) {

@@ -7,0 +14,0 @@ const computedStyle = getComputedStyle(element);

@@ -5,2 +5,9 @@ import supportAnimation from '../boolean/supportAnimation.js';

/**
* Utility to get the computed animationDuration
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
export default function getElementAnimationDuration(element) {

@@ -7,0 +14,0 @@ const computedStyle = getComputedStyle(element);

@@ -5,2 +5,9 @@ import supportTransition from '../boolean/supportTransition.js';

/**
* Utility to get the computed transitionDelay
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
export default function getElementTransitionDelay(element) {

@@ -7,0 +14,0 @@ const computedStyle = getComputedStyle(element);

@@ -5,2 +5,9 @@ import supportTransition from '../boolean/supportTransition.js';

/**
* Utility to get the computed transitionDuration
* from Element in miliseconds.
*
* @param {Element} element target
* @return {Number} the value in miliseconds
*/
export default function getElementTransitionDuration(element) {

@@ -7,0 +14,0 @@ const computedStyle = getComputedStyle(element);

@@ -0,1 +1,8 @@

/**
* Utility to determine if an Element
* is partially visible in viewport.
*
* @param {Element} element target
* @return {Boolean}
*/
export default function isElementInScrollRange(element) {

@@ -2,0 +9,0 @@ const bcr = element.getBoundingClientRect();

@@ -1,2 +0,8 @@

// check if element is in viewport
/**
* Utility to determine if an Element
* is fully visible in the viewport.
*
* @param {Element} element target
* @return {Boolean}
*/
export default function isElementInViewport(element) {

@@ -3,0 +9,0 @@ const bcr = element.getBoundingClientRect();

import normalizeValue from './normalizeValue.js';
/**
* Utility to normalize component options
*
* @param {Element} element target
* @param {object} defaultOps component default options
* @param {object} inputOps component instance options
* @param {string} ns component namespace
* @return {object} normalized component options object
*/
export default function normalizeOptions(element, defaultOps, inputOps, ns) {
const normalOps = {};
const dataOps = {};
// @ts-ignore
const data = { ...element.dataset };

@@ -7,0 +17,0 @@

@@ -0,1 +1,7 @@

/**
* Utility to normalize component options
*
* @param {string | Function | Element | object} value the input value
* @return {string | Function | Element | object} the normalized value
*/
export default function normalizeValue(value) {

@@ -2,0 +8,0 @@ if (value === 'true') {

@@ -6,2 +6,4 @@ // general event options

export default supportPassive ? { passive: true } : false;
const passiveHandler = supportPassive ? { passive: true } : false;
export default passiveHandler;

@@ -0,1 +1,9 @@

/**
* Utility to check if target is typeof Element
* or find one that matches a selector.
*
* @param {string | Element} selector the input selector or target element
* @param {undefined | Element} parent optional Element to look into
* @return {null | Element} the Element
*/
export default function queryElement(selector, parent) {

@@ -2,0 +10,0 @@ const lookUp = parent && parent instanceof Element ? parent : document;

@@ -0,3 +1,10 @@

/**
* Utility to force re-paint of an Element
*
* @param {Element} element is the target
* @return {Number} the Element.offsetHeight value
*/
export default function reflow(element) {
// @ts-ignore
return element.offsetHeight;
}

@@ -0,1 +1,8 @@

/**
* Utility to wrap a callback
* in a try() catch(e)
*
* @param {Function} fn callback
* @param {string} origin callback context description
*/
export default function tryWrapper(fn, origin) {

@@ -2,0 +9,0 @@ try { fn(); } catch (e) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc