shorter-js
Advanced tools
Comparing version 0.1.8 to 0.1.9-alpha1
/*! | ||
* shorter-js v0.1.8 (https://thednp.github.io/shorter-js/) | ||
* shorter-js v0.1.9-alpha1 (https://thednp.github.io/shorter-js/) | ||
* Copyright 2019-2021 © dnp_theme | ||
@@ -112,3 +112,3 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
if (e.target === element) { | ||
handler(e); | ||
handler.apply(element, [e]); | ||
off(element, event, handlerWrapper, options); | ||
@@ -121,15 +121,26 @@ } | ||
var computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
duration = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0 | ||
propertyValue = computedStyle[animationName], | ||
durationValue = computedStyle[animationDuration], | ||
durationScale = durationValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
? parseFloat( durationValue ) * durationScale : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} | ||
function emulateAnimationEnd(element,handler){ | ||
var called = 0, duration = getElementAnimationDuration(element); | ||
duration ? element.addEventListener( animationEndEvent, function animationEndWrapper(e){ | ||
!called && handler(e); called = 1; | ||
element.removeEventListener( animationEndEvent, animationEndWrapper); | ||
}) : handler(); | ||
setTimeout(function() { !called && handler(); called = 1; }, duration || 17); | ||
var called = 0, | ||
endEvent = new Event( animationEndEvent ), | ||
duration = getElementAnimationDuration( element ); | ||
if ( duration ) { | ||
element.addEventListener( animationEndEvent, function animationEndWrapper(e){ | ||
if ( e.target === element ) { | ||
handler.apply( element, [e] ); | ||
element.removeEventListener( animationEndEvent, animationEndWrapper); | ||
called = 1; | ||
} | ||
}); | ||
setTimeout(function() { | ||
!called && element.dispatchEvent( endEvent ); | ||
}, duration + 17 ); | ||
} else { handler.apply( element, [endEvent]); } | ||
} | ||
@@ -139,15 +150,26 @@ | ||
var computedStyle = getComputedStyle(element), | ||
property = computedStyle[transitionProperty], | ||
duration = supportTransition && property && property !== 'none' | ||
? parseFloat(computedStyle[transitionDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0; | ||
propertyValue = computedStyle[transitionProperty], | ||
durationValue = computedStyle[transitionDuration], | ||
durationScale = durationValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat( durationValue ) * durationScale : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} | ||
function emulateTransitionEnd(element,handler){ | ||
var called = 0, duration = getElementTransitionDuration(element); | ||
duration ? element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ | ||
handler.apply(element,[e]); called = 1; | ||
element.removeEventListener( transitionEndEvent, transitionEndWrapper); | ||
}) : handler(); | ||
setTimeout(function() { !called && handler(); called = 1; }, duration || 17); | ||
var called = 0, | ||
endEvent = new Event( transitionEndEvent ), | ||
duration = getElementTransitionDuration(element); | ||
if ( duration ) { | ||
element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ | ||
if ( e.target === element ) { | ||
handler.apply( element, [e] ); | ||
element.removeEventListener( transitionEndEvent, transitionEndWrapper); | ||
called = 1; | ||
} | ||
}); | ||
setTimeout(function() { | ||
!called && element.dispatchEvent( endEvent ); | ||
}, duration + 17 ); | ||
} else { handler.apply( element, [endEvent]); } | ||
} | ||
@@ -175,12 +197,18 @@ | ||
var computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
delay = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDelay]) : 0; | ||
return !isNaN(delay) ? delay * 1000 : 0; | ||
propertyValue = computedStyle[animationName], | ||
durationValue = computedStyle[animationDelay], | ||
durationScale = durationValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
? parseFloat( durationValue ) * durationScale : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} | ||
function getElementTransitionDelay(element) { | ||
var duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDelay]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
return duration; | ||
var computedStyle = getComputedStyle(element), | ||
propertyValue = computedStyle[transitionProperty], | ||
delayValue = computedStyle[transitionDelay], | ||
delayScale = delayValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat( delayValue ) * delayScale : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} | ||
@@ -187,0 +215,0 @@ |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.1.8 | dnp_theme © 2021 | MIT-License | ||
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",u="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),m="webkitPerspective"in document.head.style||"perspective"in document.head.style,d=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}(),l="webkitTransform"in document.head.style||"transform"in document.head.style,b="ontouchstart"in window||navigator.msMaxTouchPoints||!1,v="webkitAnimation"in document.head.style||"animation"in document.head.style,g="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=getComputedStyle(e),i=t[o],a=v&&i&&"none"!==i?parseFloat(t[n]):0;return isNaN(a)?0:1e3*a}function E(e){var n=getComputedStyle(e),t=n[u],i=g&&t&&"none"!==t?parseFloat(n[a]):0;return isNaN(i)?0:1e3*i}var h={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:s,transitionProperty:u,isMobile:c,support3DTransform:m,supportPassive:d,supportTransform:l,supportTouch:b,supportAnimation:v,supportTransition:g,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,o=y(e);o?e.addEventListener(i,(function o(a){!t&&n(a),t=1,e.removeEventListener(i,o)})):n(),setTimeout((function(){!t&&n(),t=1}),o||17)},emulateTransitionEnd:function(e,n){var t=0,i=E(e);i?e.addEventListener(s,(function i(o){n.apply(e,[o]),t=1,e.removeEventListener(s,i)})):n(),setTimeout((function(){!t&&n(),t=1}),i||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:!!d&&{passive:!0},getElementAnimationDuration:y,getElementAnimationDelay:function(e){var n=getComputedStyle(e),i=n[o],a=v&&i&&"none"!==i?parseFloat(n[t]):0;return isNaN(a)?0:1e3*a},getElementTransitionDuration:E,getElementTransitionDelay:function(e){var n=g?parseFloat(getComputedStyle(e)[r]):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 h; | ||
// shorter-js v0.1.9-alpha1 | dnp_theme © 2021 | MIT-License | ||
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",a="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",u="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),m="webkitPerspective"in document.head.style||"perspective"in document.head.style,d=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}(),l="webkitTransform"in document.head.style||"transform"in document.head.style,b="ontouchstart"in window||navigator.msMaxTouchPoints||!1,p="webkitAnimation"in document.head.style||"animation"in document.head.style,v="webkitTransition"in document.head.style||"transition"in document.head.style;function g(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=getComputedStyle(e),i=t[a],o=t[n],u=o.indexOf("ms")>-1?1:1e3,r=p&&i&&"none"!==i?parseFloat(o)*u:0;return isNaN(r)?0:r}function E(e){var n=getComputedStyle(e),t=n[u],i=n[o],a=i.indexOf("ms")>-1?1:1e3,r=v&&t&&"none"!==t?parseFloat(i)*a:0;return isNaN(r)?0:r}var h={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:a,animationEndEvent:i,transitionDuration:o,transitionDelay:r,transitionEndEvent:s,transitionProperty:u,isMobile:c,support3DTransform:m,supportPassive:d,supportTransform:l,supportTouch:b,supportAnimation:p,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:g,off:f,one:function(e,n,t,i){g(e,n,(function a(o){o.target===e&&(t.apply(e,[o]),f(e,n,a,i))}),i)},emulateAnimationEnd:function(e,n){var t=0,a=new Event(i),o=y(e);o?(e.addEventListener(i,(function a(o){o.target===e&&(n.apply(e,[o]),e.removeEventListener(i,a),t=1)})),setTimeout((function(){!t&&e.dispatchEvent(a)}),o+17)):n.apply(e,[a])},emulateTransitionEnd:function(e,n){var t=0,i=new Event(s),a=E(e);a?(e.addEventListener(s,(function i(a){a.target===e&&(n.apply(e,[a]),e.removeEventListener(s,i),t=1)})),setTimeout((function(){!t&&e.dispatchEvent(i)}),a+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:!!d&&{passive:!0},getElementAnimationDuration:y,getElementAnimationDelay:function(e){var n=getComputedStyle(e),i=n[a],o=n[t],u=o.indexOf("ms")>-1?1:1e3,r=p&&i&&"none"!==i?parseFloat(o)*u:0;return isNaN(r)?0:r},getElementTransitionDuration:E,getElementTransitionDelay:function(e){var n=getComputedStyle(e),t=n[u],i=n[r],a=i.indexOf("ms")>-1?1:1e3,o=v&&t&&"none"!==t?parseFloat(i)*a:0;return isNaN(o)?0:o},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 h; |
/*! | ||
* shorter-js v0.1.8 (https://thednp.github.io/shorter-js/) | ||
* shorter-js v0.1.9-alpha1 (https://thednp.github.io/shorter-js/) | ||
* Copyright 2019-2021 © dnp_theme | ||
@@ -118,3 +118,3 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
if (e.target === element) { | ||
handler(e); | ||
handler.apply(element, [e]); | ||
off(element, event, handlerWrapper, options); | ||
@@ -127,15 +127,26 @@ } | ||
var computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
duration = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0 | ||
propertyValue = computedStyle[animationName], | ||
durationValue = computedStyle[animationDuration], | ||
durationScale = durationValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
? parseFloat( durationValue ) * durationScale : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} | ||
function emulateAnimationEnd(element,handler){ | ||
var called = 0, duration = getElementAnimationDuration(element); | ||
duration ? element.addEventListener( animationEndEvent, function animationEndWrapper(e){ | ||
!called && handler(e); called = 1; | ||
element.removeEventListener( animationEndEvent, animationEndWrapper); | ||
}) : handler(); | ||
setTimeout(function() { !called && handler(); called = 1; }, duration || 17); | ||
var called = 0, | ||
endEvent = new Event( animationEndEvent ), | ||
duration = getElementAnimationDuration( element ); | ||
if ( duration ) { | ||
element.addEventListener( animationEndEvent, function animationEndWrapper(e){ | ||
if ( e.target === element ) { | ||
handler.apply( element, [e] ); | ||
element.removeEventListener( animationEndEvent, animationEndWrapper); | ||
called = 1; | ||
} | ||
}); | ||
setTimeout(function() { | ||
!called && element.dispatchEvent( endEvent ); | ||
}, duration + 17 ); | ||
} else { handler.apply( element, [endEvent]); } | ||
} | ||
@@ -145,15 +156,26 @@ | ||
var computedStyle = getComputedStyle(element), | ||
property = computedStyle[transitionProperty], | ||
duration = supportTransition && property && property !== 'none' | ||
? parseFloat(computedStyle[transitionDuration]) : 0; | ||
return !isNaN(duration) ? duration * 1000 : 0; | ||
propertyValue = computedStyle[transitionProperty], | ||
durationValue = computedStyle[transitionDuration], | ||
durationScale = durationValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat( durationValue ) * durationScale : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} | ||
function emulateTransitionEnd(element,handler){ | ||
var called = 0, duration = getElementTransitionDuration(element); | ||
duration ? element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ | ||
handler.apply(element,[e]); called = 1; | ||
element.removeEventListener( transitionEndEvent, transitionEndWrapper); | ||
}) : handler(); | ||
setTimeout(function() { !called && handler(); called = 1; }, duration || 17); | ||
var called = 0, | ||
endEvent = new Event( transitionEndEvent ), | ||
duration = getElementTransitionDuration(element); | ||
if ( duration ) { | ||
element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ | ||
if ( e.target === element ) { | ||
handler.apply( element, [e] ); | ||
element.removeEventListener( transitionEndEvent, transitionEndWrapper); | ||
called = 1; | ||
} | ||
}); | ||
setTimeout(function() { | ||
!called && element.dispatchEvent( endEvent ); | ||
}, duration + 17 ); | ||
} else { handler.apply( element, [endEvent]); } | ||
} | ||
@@ -181,12 +203,18 @@ | ||
var computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
delay = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDelay]) : 0; | ||
return !isNaN(delay) ? delay * 1000 : 0; | ||
propertyValue = computedStyle[animationName], | ||
durationValue = computedStyle[animationDelay], | ||
durationScale = durationValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
? parseFloat( durationValue ) * durationScale : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} | ||
function getElementTransitionDelay(element) { | ||
var duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDelay]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
return duration; | ||
var computedStyle = getComputedStyle(element), | ||
propertyValue = computedStyle[transitionProperty], | ||
delayValue = computedStyle[transitionDelay], | ||
delayScale = delayValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat( delayValue ) * delayScale : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} | ||
@@ -193,0 +221,0 @@ |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.1.8 | 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",u="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),m="webkitPerspective"in document.head.style||"perspective"in document.head.style,d=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}(),l="webkitTransform"in document.head.style||"transform"in document.head.style,b="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 v(e,n,t,i){i=i||!1,e.addEventListener(n,t,i)}function g(e,n,t,i){i=i||!1,e.removeEventListener(n,t,i)}function y(e){var t=getComputedStyle(e),i=t[o],a=p&&i&&"none"!==i?parseFloat(t[n]):0;return isNaN(a)?0:1e3*a}function E(e){var n=getComputedStyle(e),t=n[u],i=f&&t&&"none"!==t?parseFloat(n[a]):0;return isNaN(i)?0:1e3*i}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:r,transitionEndEvent:s,transitionProperty:u,isMobile:c,support3DTransform:m,supportPassive:d,supportTransform:l,supportTouch:b,supportAnimation:p,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:g,one:function(e,n,t,i){v(e,n,(function o(a){a.target===e&&(t(a),g(e,n,o,i))}),i)},emulateAnimationEnd:function(e,n){var t=0,o=y(e);o?e.addEventListener(i,(function o(a){!t&&n(a),t=1,e.removeEventListener(i,o)})):n(),setTimeout((function(){!t&&n(),t=1}),o||17)},emulateTransitionEnd:function(e,n){var t=0,i=E(e);i?e.addEventListener(s,(function i(o){n.apply(e,[o]),t=1,e.removeEventListener(s,i)})):n(),setTimeout((function(){!t&&n(),t=1}),i||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:!!d&&{passive:!0},getElementAnimationDuration:y,getElementAnimationDelay:function(e){var n=getComputedStyle(e),i=n[o],a=p&&i&&"none"!==i?parseFloat(n[t]):0;return isNaN(a)?0:1e3*a},getElementTransitionDuration:E,getElementTransitionDelay:function(e){var n=f?parseFloat(getComputedStyle(e)[r]):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.9-alpha1 | 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",u="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),d="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}(),l="webkitTransform"in document.head.style||"transform"in document.head.style,b="ontouchstart"in window||navigator.msMaxTouchPoints||!1,p="webkitAnimation"in document.head.style||"animation"in document.head.style,v="webkitTransition"in document.head.style||"transition"in document.head.style;function f(e,n,t,i){i=i||!1,e.addEventListener(n,t,i)}function g(e,n,t,i){i=i||!1,e.removeEventListener(n,t,i)}function y(e){var t=getComputedStyle(e),i=t[o],a=t[n],u=a.indexOf("ms")>-1?1:1e3,r=p&&i&&"none"!==i?parseFloat(a)*u:0;return isNaN(r)?0:r}function E(e){var n=getComputedStyle(e),t=n[u],i=n[a],o=i.indexOf("ms")>-1?1:1e3,r=v&&t&&"none"!==t?parseFloat(i)*o:0;return isNaN(r)?0:r}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:r,transitionEndEvent:s,transitionProperty:u,isMobile:c,support3DTransform:d,supportPassive:m,supportTransform:l,supportTouch:b,supportAnimation:p,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:f,off:g,one:function(e,n,t,i){f(e,n,(function o(a){a.target===e&&(t.apply(e,[a]),g(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=E(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:!!m&&{passive:!0},getElementAnimationDuration:y,getElementAnimationDelay:function(e){var n=getComputedStyle(e),i=n[o],a=n[t],u=a.indexOf("ms")>-1?1:1e3,r=p&&i&&"none"!==i?parseFloat(a)*u:0;return isNaN(r)?0:r},getElementTransitionDuration:E,getElementTransitionDelay:function(e){var n=getComputedStyle(e),t=n[u],i=n[r],o=i.indexOf("ms")>-1?1:1e3,a=v&&t&&"none"!==t?parseFloat(i)*o:0;return isNaN(a)?0:a},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)}}}})); |
{ | ||
"name": "shorter-js", | ||
"version": "0.1.8", | ||
"version": "0.1.9-alpha1", | ||
"description": "A small ES6+ library with various JavaScript tools useful for creating light libraries.", | ||
@@ -5,0 +5,0 @@ "main": "dist/shorter-js.min.js", |
@@ -8,3 +8,3 @@ import on from './on.js' | ||
if (e.target === element) { | ||
handler(e); | ||
handler.apply(element, [e]); | ||
off(element, event, handlerWrapper, options); | ||
@@ -11,0 +11,0 @@ } |
@@ -6,8 +6,18 @@ import animationEndEvent from '../strings/animationEndEvent.js'; | ||
export default function(element,handler){ | ||
let called = 0, duration = getElementAnimationDuration(element); | ||
duration ? element.addEventListener( animationEndEvent, function animationEndWrapper(e){ | ||
!called && handler(e); called = 1 | ||
element.removeEventListener( animationEndEvent, animationEndWrapper) | ||
}) : handler() | ||
setTimeout(function() { !called && handler(); called = 1 }, duration || 17); | ||
let called = 0, | ||
endEvent = new Event( animationEndEvent ), | ||
duration = getElementAnimationDuration( element ) | ||
if ( duration ) { | ||
element.addEventListener( animationEndEvent, function animationEndWrapper(e){ | ||
if ( e.target === element ) { | ||
handler.apply( element, [e] ) | ||
element.removeEventListener( animationEndEvent, animationEndWrapper) | ||
called = 1 | ||
} | ||
}) | ||
setTimeout(function() { | ||
!called && element.dispatchEvent( endEvent ) | ||
}, duration + 17 ) | ||
} else { handler.apply( element, [endEvent]) } | ||
} |
@@ -6,8 +6,18 @@ import transitionEndEvent from '../strings/transitionEndEvent.js'; | ||
export default function(element,handler){ | ||
let called = 0, duration = getElementTransitionDuration(element); | ||
duration ? element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ | ||
handler.apply(element,[e]); called = 1 | ||
element.removeEventListener( transitionEndEvent, transitionEndWrapper) | ||
}) : handler() | ||
setTimeout(function() { !called && handler(); called = 1 }, duration || 17) | ||
let called = 0, | ||
endEvent = new Event( transitionEndEvent ), | ||
duration = getElementTransitionDuration(element) | ||
if ( duration ) { | ||
element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ | ||
if ( e.target === element ) { | ||
handler.apply( element, [e] ) | ||
element.removeEventListener( transitionEndEvent, transitionEndWrapper) | ||
called = 1 | ||
} | ||
}) | ||
setTimeout(function() { | ||
!called && element.dispatchEvent( endEvent ) | ||
}, duration + 17 ) | ||
} else { handler.apply( element, [endEvent]) } | ||
} |
@@ -7,7 +7,9 @@ import supportAnimation from '../boolean/supportAnimation.js'; | ||
let computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
delay = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDelay]) : 0; | ||
propertyValue = computedStyle[animationName], | ||
durationValue = computedStyle[animationDelay], | ||
durationScale = durationValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
? parseFloat( durationValue ) * durationScale : 0 | ||
return !isNaN(delay) ? delay * 1000 : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} |
@@ -7,7 +7,9 @@ import supportAnimation from '../boolean/supportAnimation.js'; | ||
let computedStyle = getComputedStyle(element), | ||
name = computedStyle[animationName], | ||
duration = supportAnimation && name && name !== 'none' | ||
? parseFloat(computedStyle[animationDuration]) : 0; | ||
propertyValue = computedStyle[animationName], | ||
durationValue = computedStyle[animationDuration], | ||
durationScale = durationValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportAnimation && propertyValue && propertyValue !== 'none' | ||
? parseFloat( durationValue ) * durationScale : 0 | ||
return !isNaN(duration) ? duration * 1000 : 0 | ||
return !isNaN(duration) ? duration : 0 | ||
} |
@@ -1,8 +0,14 @@ | ||
import supportTransition from '../boolean/supportTransition.js'; | ||
import transitionDelay from '../strings/transitionDelay.js'; | ||
import supportTransition from '../boolean/supportTransition.js' | ||
import transitionDelay from '../strings/transitionDelay.js' | ||
import transitionProperty from '../strings/transitionProperty.js' | ||
export default function(element) { | ||
let duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDelay]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
return duration; | ||
let computedStyle = getComputedStyle(element), | ||
propertyValue = computedStyle[transitionProperty], | ||
delayValue = computedStyle[transitionDelay], | ||
delayScale = delayValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat( delayValue ) * delayScale : 0 | ||
return !isNaN(duration) ? duration : 0 | ||
} |
@@ -1,12 +0,14 @@ | ||
import supportTransition from '../boolean/supportTransition.js'; | ||
import transitionDuration from '../strings/transitionDuration.js'; | ||
import transitionProperty from '../strings/transitionProperty.js'; | ||
import supportTransition from '../boolean/supportTransition.js' | ||
import transitionDuration from '../strings/transitionDuration.js' | ||
import transitionProperty from '../strings/transitionProperty.js' | ||
export default function(element) { | ||
let computedStyle = getComputedStyle(element), | ||
property = computedStyle[transitionProperty], | ||
duration = supportTransition && property && property !== 'none' | ||
? parseFloat(computedStyle[transitionDuration]) : 0; | ||
propertyValue = computedStyle[transitionProperty], | ||
durationValue = computedStyle[transitionDuration], | ||
durationScale = durationValue.indexOf('ms') > -1 ? 1 : 1000, | ||
duration = supportTransition && propertyValue && propertyValue !== 'none' | ||
? parseFloat( durationValue ) * durationScale : 0 | ||
return !isNaN(duration) ? duration * 1000 : 0; | ||
return !isNaN(duration) ? duration : 0 | ||
} |
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
54897
758