shorter-js
Advanced tools
Comparing version 0.1.4 to 0.1.5
/*! | ||
* shorter-js v0.1.4 (https://thednp.github.io/shorter-js/) | ||
* shorter-js v0.1.5 (https://thednp.github.io/shorter-js/) | ||
* Copyright 2019-2020 © dnp_theme | ||
@@ -14,10 +14,14 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
var animationDuration = 'webkitAnimationDuration' in document.head.style ? 'webkitAnimationDuration' : 'animationDuration'; | ||
var animationDuration = 'webkitAnimation' in document.head.style ? 'webkitAnimationDuration' : 'animationDuration'; | ||
var animationDelay = 'webkitAnimationDelay' in document.head.style ? 'webkitAnimationDelay' : 'animationDelay'; | ||
var animationDelay = 'webkitAnimation' in document.head.style ? 'webkitAnimationDelay' : 'animationDelay'; | ||
var animationEndEvent = 'webkitAnimation' in document.head.style ? 'webkitAnimationEnd' : 'animationend'; | ||
var animationName = 'webkitAnimation' in document.head.style ? 'webkitAnimationName' : 'animationName'; | ||
var transitionDuration = 'webkitTransition' in document.head.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
var transitionProperty = 'webkitTransition' in document.body.style ? 'webkitTransitionProperty' : 'transitionProperty'; | ||
var transitionDelay = 'webkitTransition' in document.head.style ? 'webkitTransitionDelay' : 'transitionDelay'; | ||
@@ -86,5 +90,7 @@ | ||
function getElementAnimationDuration(element) { | ||
var duration = supportAnimation ? parseFloat(getComputedStyle(element)[animationDuration]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
return duration; | ||
var computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
duration = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0 | ||
} | ||
@@ -102,5 +108,7 @@ | ||
function getElementTransitionDuration(element) { | ||
var duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDuration]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
return duration; | ||
var computedStyle = getComputedStyle(element), | ||
property = computedStyle[transitionProperty], | ||
duration = supportTransition && property && property !== 'none' | ||
? parseFloat(computedStyle[transitionDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0; | ||
} | ||
@@ -136,5 +144,7 @@ | ||
function getElementAnimationDelay(element) { | ||
var delay = supportAnimation ? parseFloat(getComputedStyle(element)[animationDelay]) : 0; | ||
delay = typeof delay === 'number' && !isNaN(delay) ? delay * 1000 : 0; | ||
return delay; | ||
var computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
delay = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDelay]) : 0; | ||
return !isNaN(delay) ? delay * 1000 : 0; | ||
} | ||
@@ -167,6 +177,8 @@ | ||
animationDelay: animationDelay, | ||
animationName: animationName, | ||
animationEndEvent: animationEndEvent, | ||
transitionDuration: transitionDuration, | ||
transitionDelay: transitionDelay, | ||
animationEndEvent: animationEndEvent, | ||
transitionEndEvent: transitionEndEvent, | ||
transitionProperty: transitionProperty, | ||
isMobile: isMobile, | ||
@@ -173,0 +185,0 @@ support3DTransform: support3DTransform, |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.1.4 | dnp_theme © 2020 | MIT-License | ||
var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n="webkitAnimationDuration"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimationDelay"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",r="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",s=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),u="webkitPerspective"in document.head.style||"perspective"in document.head.style,m=function(){var e=!1;try{var n=Object.defineProperty({},"passive",{get:function(){e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}catch(e){}return e}(),d="webkitTransform"in document.head.style||"transform"in document.head.style,c="ontouchstart"in window||navigator.msMaxTouchPoints||!1,l="webkitAnimation"in document.head.style||"animation"in document.head.style,v="webkitTransition"in document.head.style||"transition"in document.head.style;function p(e,n,t,i){i=i||!1,e.addEventListener(n,t,i)}function f(e,n,t,i){i=i||!1,e.removeEventListener(n,t,i)}function y(e){var t=l?parseFloat(getComputedStyle(e)[n]):0;return t="number"!=typeof t||isNaN(t)?0:1e3*t}function h(e){var n=v?parseFloat(getComputedStyle(e)[o]):0;return n="number"!=typeof n||isNaN(n)?0:1e3*n}var E={mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},animationDuration:n,animationDelay:t,transitionDuration:o,transitionDelay:a,animationEndEvent:i,transitionEndEvent:r,isMobile:s,support3DTransform:u,supportPassive:m,supportTransform:d,supportTouch:c,supportAnimation:l,supportTransition:v,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:p,off:f,one:function(e,n,t,i){p(e,n,(function o(a){a.target===e&&(t(a),f(e,n,o,i))}),i)},emulateAnimationEnd:function(e,n){var t=0;y(e)?e.addEventListener(i,(function o(a){!t&&n(a),t=1,e.removeEventListener(i,o)})):setTimeout((function(){!t&&n(),t=1}),17)},emulateTransitionEnd:function(e,n){var t=0;h(e)?e.addEventListener(r,(function i(o){!t&&n(o),t=1,e.removeEventListener(r,i)})):setTimeout((function(){!t&&n(),t=1}),17)},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:!!m&&{passive:!0},getElementAnimationDuration:y,getElementAnimationDelay:function(e){var n=l?parseFloat(getComputedStyle(e)[t]):0;return n="number"!=typeof n||isNaN(n)?0:1e3*n},getElementTransitionDuration:h,getElementTransitionDelay:function(e){var n=v?parseFloat(getComputedStyle(e)[a]):0;return n="number"!=typeof n||isNaN(n)?0:1e3*n},queryElement:function(e,n){var t=n&&n instanceof Element?n:document;return e instanceof Element?e:t.querySelector(e)},tryWrapper:function(e,n){try{e()}catch(e){console.error(n+" "+e)}}};export default E; | ||
// shorter-js v0.1.5 | dnp_theme © 2020 | MIT-License | ||
var n="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",e="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.body.style?"webkitTransitionProperty":"transitionProperty",s="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",m=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),d="webkitPerspective"in document.head.style||"perspective"in document.head.style,c=function(){var n=!1;try{var t=Object.defineProperty({},"passive",{get:function(){n=!0}});document.addEventListener("DOMContentLoaded",(function n(){document.removeEventListener("DOMContentLoaded",n,t)}),t)}catch(n){}return n}(),l="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,y="webkitTransition"in document.head.style||"transition"in document.head.style;function f(n,t,e,i){i=i||!1,n.addEventListener(t,e,i)}function h(n,t,e,i){i=i||!1,n.removeEventListener(t,e,i)}function w(n){var e=getComputedStyle(n),i=e[o],a=p&&i&&"none"!==i?parseFloat(e[t]):0;return isNaN(a)?0:1e3*a}function E(n){var t=getComputedStyle(n),e=t[r],i=y&&e&&"none"!==e?parseFloat(t[a]):0;return isNaN(i)?0:1e3*i}var b={mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:n,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},animationDuration:t,animationDelay:e,animationName:o,animationEndEvent:i,transitionDuration:a,transitionDelay:s,transitionEndEvent:u,transitionProperty:r,isMobile:m,support3DTransform:d,supportPassive:c,supportTransform:l,supportTouch:v,supportAnimation:p,supportTransition:y,addClass:function(n,t){n.classList.add(t)},removeClass:function(n,t){n.classList.remove(t)},hasClass:function(n,t){return n.classList.contains(t)},on:f,off:h,one:function(n,t,e,i){f(n,t,(function o(a){a.target===n&&(e(a),h(n,t,o,i))}),i)},emulateAnimationEnd:function(n,t){var e=0;w(n)?n.addEventListener(i,(function o(a){!e&&t(a),e=1,n.removeEventListener(i,o)})):setTimeout((function(){!e&&t(),e=1}),17)},emulateTransitionEnd:function(n,t){var e=0;E(n)?n.addEventListener(u,(function i(o){!e&&t(o),e=1,n.removeEventListener(u,i)})):setTimeout((function(){!e&&t(),e=1}),17)},isElementInScrollRange:function(n){var t=n.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight;return t.top<=e&&t.bottom>=0},isElementInViewport:function(n){var t=n.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!c&&{passive:!0},getElementAnimationDuration:w,getElementAnimationDelay:function(n){var t=getComputedStyle(n),i=t[o],a=p&&i&&"none"!==i?parseFloat(t[e]):0;return isNaN(a)?0:1e3*a},getElementTransitionDuration:E,getElementTransitionDelay:function(n){var t=y?parseFloat(getComputedStyle(n)[s]):0;return t="number"!=typeof t||isNaN(t)?0:1e3*t},queryElement:function(n,t){var e=t&&t instanceof Element?t:document;return n instanceof Element?n:e.querySelector(n)},tryWrapper:function(n,t){try{n()}catch(n){console.error(t+" "+n)}}};export default b; |
/*! | ||
* shorter-js v0.1.4 (https://thednp.github.io/shorter-js/) | ||
* shorter-js v0.1.5 (https://thednp.github.io/shorter-js/) | ||
* Copyright 2019-2020 © dnp_theme | ||
@@ -20,10 +20,14 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
var animationDuration = 'webkitAnimationDuration' in document.head.style ? 'webkitAnimationDuration' : 'animationDuration'; | ||
var animationDuration = 'webkitAnimation' in document.head.style ? 'webkitAnimationDuration' : 'animationDuration'; | ||
var animationDelay = 'webkitAnimationDelay' in document.head.style ? 'webkitAnimationDelay' : 'animationDelay'; | ||
var animationDelay = 'webkitAnimation' in document.head.style ? 'webkitAnimationDelay' : 'animationDelay'; | ||
var animationEndEvent = 'webkitAnimation' in document.head.style ? 'webkitAnimationEnd' : 'animationend'; | ||
var animationName = 'webkitAnimation' in document.head.style ? 'webkitAnimationName' : 'animationName'; | ||
var transitionDuration = 'webkitTransition' in document.head.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
var transitionProperty = 'webkitTransition' in document.body.style ? 'webkitTransitionProperty' : 'transitionProperty'; | ||
var transitionDelay = 'webkitTransition' in document.head.style ? 'webkitTransitionDelay' : 'transitionDelay'; | ||
@@ -92,5 +96,7 @@ | ||
function getElementAnimationDuration(element) { | ||
var duration = supportAnimation ? parseFloat(getComputedStyle(element)[animationDuration]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
return duration; | ||
var computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
duration = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0 | ||
} | ||
@@ -108,5 +114,7 @@ | ||
function getElementTransitionDuration(element) { | ||
var duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDuration]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
return duration; | ||
var computedStyle = getComputedStyle(element), | ||
property = computedStyle[transitionProperty], | ||
duration = supportTransition && property && property !== 'none' | ||
? parseFloat(computedStyle[transitionDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0; | ||
} | ||
@@ -142,5 +150,7 @@ | ||
function getElementAnimationDelay(element) { | ||
var delay = supportAnimation ? parseFloat(getComputedStyle(element)[animationDelay]) : 0; | ||
delay = typeof delay === 'number' && !isNaN(delay) ? delay * 1000 : 0; | ||
return delay; | ||
var computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
delay = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDelay]) : 0; | ||
return !isNaN(delay) ? delay * 1000 : 0; | ||
} | ||
@@ -173,6 +183,8 @@ | ||
animationDelay: animationDelay, | ||
animationName: animationName, | ||
animationEndEvent: animationEndEvent, | ||
transitionDuration: transitionDuration, | ||
transitionDelay: transitionDelay, | ||
animationEndEvent: animationEndEvent, | ||
transitionEndEvent: transitionEndEvent, | ||
transitionProperty: transitionProperty, | ||
isMobile: isMobile, | ||
@@ -179,0 +191,0 @@ support3DTransform: support3DTransform, |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.1.4 | dnp_theme © 2020 | 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="webkitAnimationDuration"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimationDelay"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",r="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",s=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),u="webkitPerspective"in document.head.style||"perspective"in document.head.style,m=function(){var e=!1;try{var n=Object.defineProperty({},"passive",{get:function(){e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}catch(e){}return e}(),d="webkitTransform"in document.head.style||"transform"in document.head.style,c="ontouchstart"in window||navigator.msMaxTouchPoints||!1,l="webkitAnimation"in document.head.style||"animation"in document.head.style,f="webkitTransition"in document.head.style||"transition"in document.head.style;function v(e,n,t,i){i=i||!1,e.addEventListener(n,t,i)}function p(e,n,t,i){i=i||!1,e.removeEventListener(n,t,i)}function y(e){var t=l?parseFloat(getComputedStyle(e)[n]):0;return t="number"!=typeof t||isNaN(t)?0:1e3*t}function h(e){var n=f?parseFloat(getComputedStyle(e)[o]):0;return n="number"!=typeof n||isNaN(n)?0:1e3*n}return{mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},animationDuration:n,animationDelay:t,transitionDuration:o,transitionDelay:a,animationEndEvent:i,transitionEndEvent:r,isMobile:s,support3DTransform:u,supportPassive:m,supportTransform:d,supportTouch:c,supportAnimation:l,supportTransition:f,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:v,off:p,one:function(e,n,t,i){v(e,n,(function o(a){a.target===e&&(t(a),p(e,n,o,i))}),i)},emulateAnimationEnd:function(e,n){var t=0;y(e)?e.addEventListener(i,(function o(a){!t&&n(a),t=1,e.removeEventListener(i,o)})):setTimeout((function(){!t&&n(),t=1}),17)},emulateTransitionEnd:function(e,n){var t=0;h(e)?e.addEventListener(r,(function i(o){!t&&n(o),t=1,e.removeEventListener(r,i)})):setTimeout((function(){!t&&n(),t=1}),17)},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:!!m&&{passive:!0},getElementAnimationDuration:y,getElementAnimationDelay:function(e){var n=l?parseFloat(getComputedStyle(e)[t]):0;return n="number"!=typeof n||isNaN(n)?0:1e3*n},getElementTransitionDuration:h,getElementTransitionDelay:function(e){var n=f?parseFloat(getComputedStyle(e)[a]):0;return n="number"!=typeof n||isNaN(n)?0:1e3*n},queryElement:function(e,n){var t=n&&n instanceof Element?n:document;return e instanceof Element?e:t.querySelector(e)},tryWrapper:function(e,n){try{e()}catch(e){console.error(n+" "+e)}}}})); | ||
// shorter-js v0.1.5 | dnp_theme © 2020 | MIT-License | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n=n||self).SHORTER=e()}(this,(function(){"use strict";var n="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],e="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.body.style?"webkitTransitionProperty":"transitionProperty",s="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",m=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),d="webkitPerspective"in document.head.style||"perspective"in document.head.style,c=function(){var n=!1;try{var e=Object.defineProperty({},"passive",{get:function(){n=!0}});document.addEventListener("DOMContentLoaded",(function n(){document.removeEventListener("DOMContentLoaded",n,e)}),e)}catch(n){}return n}(),l="webkitTransform"in document.head.style||"transform"in document.head.style,v="ontouchstart"in window||navigator.msMaxTouchPoints||!1,f="webkitAnimation"in document.head.style||"animation"in document.head.style,p="webkitTransition"in document.head.style||"transition"in document.head.style;function y(n,e,t,i){i=i||!1,n.addEventListener(e,t,i)}function h(n,e,t,i){i=i||!1,n.removeEventListener(e,t,i)}function w(n){var t=getComputedStyle(n),i=t[o],a=f&&i&&"none"!==i?parseFloat(t[e]):0;return isNaN(a)?0:1e3*a}function E(n){var e=getComputedStyle(n),t=e[r],i=p&&t&&"none"!==t?parseFloat(e[a]):0;return isNaN(i)?0:1e3*i}return{mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:n,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},animationDuration:e,animationDelay:t,animationName:o,animationEndEvent:i,transitionDuration:a,transitionDelay:s,transitionEndEvent:u,transitionProperty:r,isMobile:m,support3DTransform:d,supportPassive:c,supportTransform:l,supportTouch:v,supportAnimation:f,supportTransition:p,addClass:function(n,e){n.classList.add(e)},removeClass:function(n,e){n.classList.remove(e)},hasClass:function(n,e){return n.classList.contains(e)},on:y,off:h,one:function(n,e,t,i){y(n,e,(function o(a){a.target===n&&(t(a),h(n,e,o,i))}),i)},emulateAnimationEnd:function(n,e){var t=0;w(n)?n.addEventListener(i,(function o(a){!t&&e(a),t=1,n.removeEventListener(i,o)})):setTimeout((function(){!t&&e(),t=1}),17)},emulateTransitionEnd:function(n,e){var t=0;E(n)?n.addEventListener(u,(function i(o){!t&&e(o),t=1,n.removeEventListener(u,i)})):setTimeout((function(){!t&&e(),t=1}),17)},isElementInScrollRange:function(n){var e=n.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight;return e.top<=t&&e.bottom>=0},isElementInViewport:function(n){var e=n.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!c&&{passive:!0},getElementAnimationDuration:w,getElementAnimationDelay:function(n){var e=getComputedStyle(n),i=e[o],a=f&&i&&"none"!==i?parseFloat(e[t]):0;return isNaN(a)?0:1e3*a},getElementTransitionDuration:E,getElementTransitionDelay:function(n){var e=p?parseFloat(getComputedStyle(n)[s]):0;return e="number"!=typeof e||isNaN(e)?0:1e3*e},queryElement:function(n,e){var t=e&&e instanceof Element?e:document;return n instanceof Element?n:t.querySelector(n)},tryWrapper:function(n,e){try{n()}catch(n){console.error(e+" "+n)}}}})); |
{ | ||
"name": "shorter-js", | ||
"version": "0.1.4", | ||
"description": "A small ES6/ES7 library with various JavaScript tools useful for creating light libraries.", | ||
"version": "0.1.5", | ||
"description": "A small ES6+ library with various JavaScript tools useful for creating light libraries.", | ||
"main": "dist/shorter-js.min.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/shorter-js.esm.js", |
# shorter-js | ||
**A small ES6/ES7 library with various JavaScript tools useful for creating light libraries. | ||
**A small ES6+ library with various JavaScript tools useful for creating light libraries. | ||
Featured in [KUTE.js](https://github.com/thednp/kute.js), [BSN](https://github.com/thednp/bootstrap.native), [Navbar.js](https://github.com/thednp/navbar.js) and other libraries.** | ||
@@ -13,3 +13,3 @@ | ||
# ES6/ES7 Base usage | ||
# ES6+ Base usage | ||
```js | ||
@@ -117,5 +117,7 @@ // import the tool you need | ||
* ***animationEndEvent*** - preserves the `animationEndEvent` event name supported by the client browser | ||
* ***animationName*** - preserves the `animationName` property name supported by the client browser | ||
* ***transitionDuration*** - preserves the `transitionDuration` property name supported by the client browser | ||
* ***transitionDelay*** - preserves the `transitionDelay` property name supported by the client browser | ||
* ***transitionEndEvent*** - preserves the `transitionend` event name supported by the client browser | ||
* ***transitionProperty*** - preserves the `transitionProperty` property name supported by the client browser | ||
@@ -135,3 +137,3 @@ ```js | ||
# Advanced Use | ||
To avoid adding un-necessary shorties into your code, you might want to import them directly from their location | ||
To avoid adding un-necessary shorties into your code, you might want to import them directly from their location. | ||
@@ -142,2 +144,6 @@ ```js | ||
import addClass from 'shorter-js/src/class/addClass.js' | ||
on(document.getElementById('my-elem'),'eventName',function(e){ | ||
addClass(document.getElementById('my-elem'),'my-className') | ||
}) | ||
``` | ||
@@ -144,0 +150,0 @@ |
@@ -9,3 +9,5 @@ // strings FIRST | ||
import animationEndEvent from './strings/animationEndEvent.js' | ||
import animationName from './strings/animationName.js' | ||
import transitionDuration from './strings/transitionDuration.js' | ||
import transitionProperty from './strings/transitionProperty.js' | ||
import transitionDelay from './strings/transitionDelay.js' | ||
@@ -53,6 +55,8 @@ import transitionEndEvent from './strings/transitionEndEvent.js' | ||
animationDelay, | ||
animationName, | ||
animationEndEvent, | ||
transitionDuration, | ||
transitionDelay, | ||
animationEndEvent, | ||
transitionEndEvent, | ||
transitionProperty, | ||
isMobile, | ||
@@ -59,0 +63,0 @@ support3DTransform, |
@@ -1,2 +0,1 @@ | ||
// import one from '../event/one.js'; | ||
import transitionEndEvent from '../strings/transitionEndEvent.js'; | ||
@@ -3,0 +2,0 @@ import getElementTransitionDuration from './getElementTransitionDuration.js'; |
import supportAnimation from '../boolean/supportAnimation.js'; | ||
import animationDelay from '../strings/animationDelay.js'; | ||
import animationName from '../strings/animationName.js'; | ||
export default function(element) { | ||
let delay = supportAnimation ? parseFloat(getComputedStyle(element)[animationDelay]) : 0; | ||
delay = typeof delay === 'number' && !isNaN(delay) ? delay * 1000 : 0; | ||
return delay; | ||
let computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
delay = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDelay]) : 0; | ||
return !isNaN(delay) ? delay * 1000 : 0; | ||
} |
import supportAnimation from '../boolean/supportAnimation.js'; | ||
import animationDuration from '../strings/animationDuration.js'; | ||
import animationName from '../strings/animationName.js'; | ||
export default function(element) { | ||
let duration = supportAnimation ? parseFloat(getComputedStyle(element)[animationDuration]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
return duration; | ||
let computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
duration = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0 | ||
} |
import supportTransition from '../boolean/supportTransition.js'; | ||
import transitionDuration from '../strings/transitionDuration.js'; | ||
import transitionProperty from '../strings/transitionProperty.js'; | ||
export default function(element) { | ||
let duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDuration]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
return duration; | ||
let computedStyle = getComputedStyle(element), | ||
property = computedStyle[transitionProperty], | ||
duration = supportTransition && property && property !== 'none' | ||
? parseFloat(computedStyle[transitionDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0; | ||
} |
@@ -1,1 +0,1 @@ | ||
export default 'webkitAnimationDelay' in document.head.style ? 'webkitAnimationDelay' : 'animationDelay'; | ||
export default 'webkitAnimation' in document.head.style ? 'webkitAnimationDelay' : 'animationDelay'; |
@@ -1,1 +0,1 @@ | ||
export default 'webkitAnimationDuration' in document.head.style ? 'webkitAnimationDuration' : 'animationDuration'; | ||
export default 'webkitAnimation' in document.head.style ? 'webkitAnimationDuration' : 'animationDuration'; |
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
43468
44
571
149