shorter-js
Advanced tools
Comparing version 0.0.9 to 0.1.0
/*! | ||
* shorter-js v0.0.9 (https://thednp.github.io/shorter-js/) | ||
* shorter-js v0.1.0 (https://thednp.github.io/shorter-js/) | ||
* Copyright 2019-2020 © dnp_theme | ||
* Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
*/ | ||
var mouseClickEvents$1 = mouseClickEvents = { down: 'mousedown', up: 'mouseup' }; | ||
var mouseClickEvents = { down: 'mousedown', up: 'mouseup' }; | ||
var mouseHoverEvents$1 = mouseHoverEvents = ('onmouseleave' in document) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ]; | ||
var mouseHoverEvents = ('onmouseleave' in document) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ]; | ||
var touchEvents$1 = touchEvents = { start: 'touchstart', end: 'touchend', move:'touchmove', cancel:'touchcancel' }; | ||
var touchEvents = { start: 'touchstart', end: 'touchend', move:'touchmove', cancel:'touchcancel' }; | ||
var mouseSwipeEvents$1 = mouseSwipeEvents = { start: 'mousedown', end: 'mouseup', move:'mousemove', cancel:'mouseout' }; | ||
var mouseSwipeEvents = { start: 'mousedown', end: 'mouseup', move:'mousemove', cancel:'mouseout' }; | ||
var transitionDuration$1 = transitionDuration = 'webkitTransition' in document.body.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
var transitionDuration = 'webkitTransition' in document.body.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
var transitionEndEvent$1 = transitionEndEvent = 'webkitTransition' in document.body.style ? 'webkitTransitionEnd' : 'transitionend'; | ||
var transitionEndEvent = 'webkitTransition' in document.body.style ? 'webkitTransitionEnd' : 'transitionend'; | ||
var isMobile$1 = isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); | ||
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); | ||
var support3DTransform$1 = support3DTransform = 'webkitPerspective' in document.body.style || 'perspective' in document.body.style; | ||
var support3DTransform = 'webkitPerspective' in document.body.style || 'perspective' in document.body.style; | ||
var supportPassive$1 = supportPassive = (function () { | ||
var supportPassive = (function () { | ||
var result = false; | ||
@@ -37,7 +37,7 @@ try { | ||
var supportTransform$1 = supportTransform = 'webkitTransform' in document.body.style || 'transform' in document.body.style; | ||
var supportTransform = 'webkitTransform' in document.body.style || 'transform' in document.body.style; | ||
var supportTouch$1 = supportTouch = ('ontouchstart' in window || navigator.msMaxTouchPoints) || false; | ||
var supportTouch = ('ontouchstart' in window || navigator.msMaxTouchPoints) || false; | ||
var supportTransition$1 = supportTransition = 'webkitTransition' in document.body.style || 'transition' in document.body.style; | ||
var supportTransition = 'webkitTransition' in document.body.style || 'transition' in document.body.style; | ||
@@ -56,3 +56,3 @@ function addClass(element,classNAME) { | ||
function on (element, event, handler, options) { | ||
function on(element, event, handler, options) { | ||
options = options || false; | ||
@@ -62,3 +62,3 @@ element.addEventListener(event, handler, options); | ||
function off (element, event, handler, options) { | ||
function off(element, event, handler, options) { | ||
options = options || false; | ||
@@ -68,3 +68,3 @@ element.removeEventListener(event, handler, options); | ||
function one (element, event, handler, options) { | ||
function one(element, event, handler, options) { | ||
on(element, event, function handlerWrapper(e){ | ||
@@ -78,4 +78,4 @@ if (e.target === element) { | ||
function getElementTransitionDuration (element) { | ||
var duration = supportTransition$1 ? parseFloat(getComputedStyle(element)[transitionDuration$1]) : 0; | ||
function getElementTransitionDuration(element) { | ||
var duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDuration]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
@@ -85,7 +85,7 @@ return duration; | ||
function emulateTransitionEnd (element,handler){ | ||
function emulateTransitionEnd(element,handler){ | ||
var called = 0, duration = getElementTransitionDuration(element); | ||
duration ? element.addEventListener( transitionEndEvent$1, function transitionEndWrapper(e){ | ||
duration ? element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ | ||
!called && handler(e), called = 1; | ||
element.removeEventListener( transitionEndEvent$1, transitionEndWrapper); | ||
element.removeEventListener( transitionEndEvent, transitionEndWrapper); | ||
}) | ||
@@ -111,5 +111,5 @@ : setTimeout(function() { !called && handler(), called = 1; }, 17); | ||
var passiveHandler$1 = passiveHandler = supportPassive$1 ? { passive: true } : false; | ||
var passiveHandler = supportPassive ? { passive: true } : false; | ||
function queryElement (selector, parent) { | ||
function queryElement(selector, parent) { | ||
var lookUp = parent && parent instanceof Element ? parent : document; | ||
@@ -119,3 +119,3 @@ return selector instanceof Element ? selector : lookUp.querySelector(selector); | ||
function tryWrapper (fn,origin){ | ||
function tryWrapper(fn,origin){ | ||
try{ fn(); } | ||
@@ -128,14 +128,14 @@ catch(e){ | ||
var index = { | ||
mouseClickEvents: mouseClickEvents$1, | ||
mouseHoverEvents: mouseHoverEvents$1, | ||
touchEvents: touchEvents$1, | ||
mouseSwipeEvents: mouseSwipeEvents$1, | ||
transitionDuration: transitionDuration$1, | ||
transitionEndEvent: transitionEndEvent$1, | ||
isMobile: isMobile$1, | ||
support3DTransform: support3DTransform$1, | ||
supportPassive: supportPassive$1, | ||
supportTransform: supportTransform$1, | ||
supportTouch: supportTouch$1, | ||
supportTransition: supportTransition$1, | ||
mouseClickEvents: mouseClickEvents, | ||
mouseHoverEvents: mouseHoverEvents, | ||
touchEvents: touchEvents, | ||
mouseSwipeEvents: mouseSwipeEvents, | ||
transitionDuration: transitionDuration, | ||
transitionEndEvent: transitionEndEvent, | ||
isMobile: isMobile, | ||
support3DTransform: support3DTransform, | ||
supportPassive: supportPassive, | ||
supportTransform: supportTransform, | ||
supportTouch: supportTouch, | ||
supportTransition: supportTransition, | ||
addClass: addClass, | ||
@@ -150,3 +150,3 @@ removeClass: removeClass, | ||
isElementInViewport: isElementInViewport, | ||
passiveHandler: passiveHandler$1, | ||
passiveHandler: passiveHandler, | ||
getElementTransitionDuration: getElementTransitionDuration, | ||
@@ -153,0 +153,0 @@ queryElement: queryElement, |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.0.9 | dnp_theme © 2020 | MIT-License | ||
var t=mouseClickEvents={down:"mousedown",up:"mouseup"},e=mouseHoverEvents="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n=touchEvents={start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},o=mouseSwipeEvents={start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},i=transitionDuration="webkitTransition"in document.body.style?"webkitTransitionDuration":"transitionDuration",s=transitionEndEvent="webkitTransition"in document.body.style?"webkitTransitionEnd":"transitionend",r=isMobile=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),u=support3DTransform="webkitPerspective"in document.body.style||"perspective"in document.body.style,a=supportPassive=function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});document.addEventListener("DOMContentLoaded",(function t(){document.removeEventListener("DOMContentLoaded",t,e)}),e)}catch(t){}return t}(),c=supportTransform="webkitTransform"in document.body.style||"transform"in document.body.style,d=supportTouch="ontouchstart"in window||navigator.msMaxTouchPoints||!1,m=supportTransition="webkitTransition"in document.body.style||"transition"in document.body.style;function v(t,e,n,o){o=o||!1,t.addEventListener(e,n,o)}function l(t,e,n,o){o=o||!1,t.removeEventListener(e,n,o)}function p(t){var e=m?parseFloat(getComputedStyle(t)[i]):0;return e="number"!=typeof e||isNaN(e)?0:1e3*e}var f=passiveHandler=!!a&&{passive:!0};var E={mouseClickEvents:t,mouseHoverEvents:e,touchEvents:n,mouseSwipeEvents:o,transitionDuration:i,transitionEndEvent:s,isMobile:r,support3DTransform:u,supportPassive:a,supportTransform:c,supportTouch:d,supportTransition:m,addClass:function(t,e){t.classList.add(e)},removeClass:function(t,e){t.classList.remove(e)},hasClass:function(t,e){return t.classList.contains(e)},on:v,off:l,one:function(t,e,n,o){v(t,e,(function i(s){s.target===t&&(n(s),l(t,e,i,o))}),o)},emulateTransitionEnd:function(t,e){var n=0;p(t)?t.addEventListener(s,(function o(i){!n&&e(i),n=1,t.removeEventListener(s,o)})):setTimeout((function(){!n&&e(),n=1}),17)},isElementInScrollRange:function(t){var e=t.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return e.top<=n&&e.bottom>=0},isElementInViewport:function(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:f,getElementTransitionDuration:p,queryElement:function(t,e){var n=e&&e instanceof Element?e:document;return t instanceof Element?t:n.querySelector(t)},tryWrapper:function(t,e){try{t()}catch(t){console.error(e+" "+t)}}};export default E; | ||
// shorter-js v0.1.0 | dnp_theme © 2020 | MIT-License | ||
var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitTransition"in document.body.style?"webkitTransitionDuration":"transitionDuration",n="webkitTransition"in document.body.style?"webkitTransitionEnd":"transitionend",o=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),i="webkitPerspective"in document.body.style||"perspective"in document.body.style,r=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,t)}),t)}catch(e){}return e}(),s="webkitTransform"in document.body.style||"transform"in document.body.style,u="ontouchstart"in window||navigator.msMaxTouchPoints||!1,a="webkitTransition"in document.body.style||"transition"in document.body.style;function c(e,t,n,o){o=o||!1,e.addEventListener(t,n,o)}function d(e,t,n,o){o=o||!1,e.removeEventListener(t,n,o)}function m(e){var n=a?parseFloat(getComputedStyle(e)[t]):0;return n="number"!=typeof n||isNaN(n)?0:1e3*n}var l={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"},transitionDuration:t,transitionEndEvent:n,isMobile:o,support3DTransform:i,supportPassive:r,supportTransform:s,supportTouch:u,supportTransition:a,addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:c,off:d,one:function(e,t,n,o){c(e,t,(function i(r){r.target===e&&(n(r),d(e,t,i,o))}),o)},emulateTransitionEnd:function(e,t){var o=0;m(e)?e.addEventListener(n,(function i(r){!o&&t(r),o=1,e.removeEventListener(n,i)})):setTimeout((function(){!o&&t(),o=1}),17)},isElementInScrollRange:function(e){var t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){var t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!r&&{passive:!0},getElementTransitionDuration:m,queryElement:function(e,t){var n=t&&t instanceof Element?t:document;return e instanceof Element?e:n.querySelector(e)},tryWrapper:function(e,t){try{e()}catch(e){console.error(t+" "+e)}}};export default l; |
/*! | ||
* shorter-js v0.0.9 (https://thednp.github.io/shorter-js/) | ||
* shorter-js v0.1.0 (https://thednp.github.io/shorter-js/) | ||
* Copyright 2019-2020 © dnp_theme | ||
@@ -12,19 +12,19 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
var mouseClickEvents$1 = mouseClickEvents = { down: 'mousedown', up: 'mouseup' }; | ||
var mouseClickEvents = { down: 'mousedown', up: 'mouseup' }; | ||
var mouseHoverEvents$1 = mouseHoverEvents = ('onmouseleave' in document) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ]; | ||
var mouseHoverEvents = ('onmouseleave' in document) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ]; | ||
var touchEvents$1 = touchEvents = { start: 'touchstart', end: 'touchend', move:'touchmove', cancel:'touchcancel' }; | ||
var touchEvents = { start: 'touchstart', end: 'touchend', move:'touchmove', cancel:'touchcancel' }; | ||
var mouseSwipeEvents$1 = mouseSwipeEvents = { start: 'mousedown', end: 'mouseup', move:'mousemove', cancel:'mouseout' }; | ||
var mouseSwipeEvents = { start: 'mousedown', end: 'mouseup', move:'mousemove', cancel:'mouseout' }; | ||
var transitionDuration$1 = transitionDuration = 'webkitTransition' in document.body.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
var transitionDuration = 'webkitTransition' in document.body.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
var transitionEndEvent$1 = transitionEndEvent = 'webkitTransition' in document.body.style ? 'webkitTransitionEnd' : 'transitionend'; | ||
var transitionEndEvent = 'webkitTransition' in document.body.style ? 'webkitTransitionEnd' : 'transitionend'; | ||
var isMobile$1 = isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); | ||
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); | ||
var support3DTransform$1 = support3DTransform = 'webkitPerspective' in document.body.style || 'perspective' in document.body.style; | ||
var support3DTransform = 'webkitPerspective' in document.body.style || 'perspective' in document.body.style; | ||
var supportPassive$1 = supportPassive = (function () { | ||
var supportPassive = (function () { | ||
var result = false; | ||
@@ -44,7 +44,7 @@ try { | ||
var supportTransform$1 = supportTransform = 'webkitTransform' in document.body.style || 'transform' in document.body.style; | ||
var supportTransform = 'webkitTransform' in document.body.style || 'transform' in document.body.style; | ||
var supportTouch$1 = supportTouch = ('ontouchstart' in window || navigator.msMaxTouchPoints) || false; | ||
var supportTouch = ('ontouchstart' in window || navigator.msMaxTouchPoints) || false; | ||
var supportTransition$1 = supportTransition = 'webkitTransition' in document.body.style || 'transition' in document.body.style; | ||
var supportTransition = 'webkitTransition' in document.body.style || 'transition' in document.body.style; | ||
@@ -63,3 +63,3 @@ function addClass(element,classNAME) { | ||
function on (element, event, handler, options) { | ||
function on(element, event, handler, options) { | ||
options = options || false; | ||
@@ -69,3 +69,3 @@ element.addEventListener(event, handler, options); | ||
function off (element, event, handler, options) { | ||
function off(element, event, handler, options) { | ||
options = options || false; | ||
@@ -75,3 +75,3 @@ element.removeEventListener(event, handler, options); | ||
function one (element, event, handler, options) { | ||
function one(element, event, handler, options) { | ||
on(element, event, function handlerWrapper(e){ | ||
@@ -85,4 +85,4 @@ if (e.target === element) { | ||
function getElementTransitionDuration (element) { | ||
var duration = supportTransition$1 ? parseFloat(getComputedStyle(element)[transitionDuration$1]) : 0; | ||
function getElementTransitionDuration(element) { | ||
var duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDuration]) : 0; | ||
duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; | ||
@@ -92,7 +92,7 @@ return duration; | ||
function emulateTransitionEnd (element,handler){ | ||
function emulateTransitionEnd(element,handler){ | ||
var called = 0, duration = getElementTransitionDuration(element); | ||
duration ? element.addEventListener( transitionEndEvent$1, function transitionEndWrapper(e){ | ||
duration ? element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ | ||
!called && handler(e), called = 1; | ||
element.removeEventListener( transitionEndEvent$1, transitionEndWrapper); | ||
element.removeEventListener( transitionEndEvent, transitionEndWrapper); | ||
}) | ||
@@ -118,5 +118,5 @@ : setTimeout(function() { !called && handler(), called = 1; }, 17); | ||
var passiveHandler$1 = passiveHandler = supportPassive$1 ? { passive: true } : false; | ||
var passiveHandler = supportPassive ? { passive: true } : false; | ||
function queryElement (selector, parent) { | ||
function queryElement(selector, parent) { | ||
var lookUp = parent && parent instanceof Element ? parent : document; | ||
@@ -126,3 +126,3 @@ return selector instanceof Element ? selector : lookUp.querySelector(selector); | ||
function tryWrapper (fn,origin){ | ||
function tryWrapper(fn,origin){ | ||
try{ fn(); } | ||
@@ -135,14 +135,14 @@ catch(e){ | ||
var index = { | ||
mouseClickEvents: mouseClickEvents$1, | ||
mouseHoverEvents: mouseHoverEvents$1, | ||
touchEvents: touchEvents$1, | ||
mouseSwipeEvents: mouseSwipeEvents$1, | ||
transitionDuration: transitionDuration$1, | ||
transitionEndEvent: transitionEndEvent$1, | ||
isMobile: isMobile$1, | ||
support3DTransform: support3DTransform$1, | ||
supportPassive: supportPassive$1, | ||
supportTransform: supportTransform$1, | ||
supportTouch: supportTouch$1, | ||
supportTransition: supportTransition$1, | ||
mouseClickEvents: mouseClickEvents, | ||
mouseHoverEvents: mouseHoverEvents, | ||
touchEvents: touchEvents, | ||
mouseSwipeEvents: mouseSwipeEvents, | ||
transitionDuration: transitionDuration, | ||
transitionEndEvent: transitionEndEvent, | ||
isMobile: isMobile, | ||
support3DTransform: support3DTransform, | ||
supportPassive: supportPassive, | ||
supportTransform: supportTransform, | ||
supportTouch: supportTouch, | ||
supportTransition: supportTransition, | ||
addClass: addClass, | ||
@@ -157,3 +157,3 @@ removeClass: removeClass, | ||
isElementInViewport: isElementInViewport, | ||
passiveHandler: passiveHandler$1, | ||
passiveHandler: passiveHandler, | ||
getElementTransitionDuration: getElementTransitionDuration, | ||
@@ -160,0 +160,0 @@ queryElement: queryElement, |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.0.9 | dnp_theme © 2020 | MIT-License | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).SHORTER=t()}(this,(function(){"use strict";var e=mouseClickEvents={down:"mousedown",up:"mouseup"},t=mouseHoverEvents="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n=touchEvents={start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},o=mouseSwipeEvents={start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},i=transitionDuration="webkitTransition"in document.body.style?"webkitTransitionDuration":"transitionDuration",s=transitionEndEvent="webkitTransition"in document.body.style?"webkitTransitionEnd":"transitionend",r=isMobile=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),u=support3DTransform="webkitPerspective"in document.body.style||"perspective"in document.body.style,a=supportPassive=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,t)}),t)}catch(e){}return e}(),c=supportTransform="webkitTransform"in document.body.style||"transform"in document.body.style,d=supportTouch="ontouchstart"in window||navigator.msMaxTouchPoints||!1,m=supportTransition="webkitTransition"in document.body.style||"transition"in document.body.style;function l(e,t,n,o){o=o||!1,e.addEventListener(t,n,o)}function v(e,t,n,o){o=o||!1,e.removeEventListener(t,n,o)}function p(e){var t=m?parseFloat(getComputedStyle(e)[i]):0;return t="number"!=typeof t||isNaN(t)?0:1e3*t}var f=passiveHandler=!!a&&{passive:!0};return{mouseClickEvents:e,mouseHoverEvents:t,touchEvents:n,mouseSwipeEvents:o,transitionDuration:i,transitionEndEvent:s,isMobile:r,support3DTransform:u,supportPassive:a,supportTransform:c,supportTouch:d,supportTransition:m,addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:l,off:v,one:function(e,t,n,o){l(e,t,(function i(s){s.target===e&&(n(s),v(e,t,i,o))}),o)},emulateTransitionEnd:function(e,t){var n=0;p(e)?e.addEventListener(s,(function o(i){!n&&t(i),n=1,e.removeEventListener(s,o)})):setTimeout((function(){!n&&t(),n=1}),17)},isElementInScrollRange:function(e){var t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){var t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:f,getElementTransitionDuration:p,queryElement:function(e,t){var n=t&&t instanceof Element?t:document;return e instanceof Element?e:n.querySelector(e)},tryWrapper:function(e,t){try{e()}catch(e){console.error(t+" "+e)}}}})); | ||
// shorter-js v0.1.0 | dnp_theme © 2020 | MIT-License | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).SHORTER=t()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitTransition"in document.body.style?"webkitTransitionDuration":"transitionDuration",n="webkitTransition"in document.body.style?"webkitTransitionEnd":"transitionend",o=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),i="webkitPerspective"in document.body.style||"perspective"in document.body.style,s=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,t)}),t)}catch(e){}return e}(),r="webkitTransform"in document.body.style||"transform"in document.body.style,u="ontouchstart"in window||navigator.msMaxTouchPoints||!1,c="webkitTransition"in document.body.style||"transition"in document.body.style;function a(e,t,n,o){o=o||!1,e.addEventListener(t,n,o)}function d(e,t,n,o){o=o||!1,e.removeEventListener(t,n,o)}function m(e){var n=c?parseFloat(getComputedStyle(e)[t]):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"},transitionDuration:t,transitionEndEvent:n,isMobile:o,support3DTransform:i,supportPassive:s,supportTransform:r,supportTouch:u,supportTransition:c,addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:a,off:d,one:function(e,t,n,o){a(e,t,(function i(s){s.target===e&&(n(s),d(e,t,i,o))}),o)},emulateTransitionEnd:function(e,t){var o=0;m(e)?e.addEventListener(n,(function i(s){!o&&t(s),o=1,e.removeEventListener(n,i)})):setTimeout((function(){!o&&t(),o=1}),17)},isElementInScrollRange:function(e){var t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){var t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!s&&{passive:!0},getElementTransitionDuration:m,queryElement:function(e,t){var n=t&&t instanceof Element?t:document;return e instanceof Element?e:n.querySelector(e)},tryWrapper:function(e,t){try{e()}catch(e){console.error(t+" "+e)}}}})); |
{ | ||
"name": "shorter-js", | ||
"version": "0.0.9", | ||
"version": "0.1.0", | ||
"description": "A small ES6/ES7 library with various JavaScript tools useful for creating light libraries.", | ||
@@ -5,0 +5,0 @@ "main": "dist/shorter-js.min.js", |
@@ -1,1 +0,1 @@ | ||
export default isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) | ||
export default /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) |
@@ -1,1 +0,1 @@ | ||
export default support3DTransform = 'webkitPerspective' in document.body.style || 'perspective' in document.body.style; | ||
export default 'webkitPerspective' in document.body.style || 'perspective' in document.body.style; |
// determine support for passive events | ||
export default supportPassive = (() => { | ||
export default (() => { | ||
// Test via a getter in the options object to see if the passive property is accessed | ||
@@ -4,0 +4,0 @@ let result = false; |
@@ -1,1 +0,1 @@ | ||
export default supportTouch = ('ontouchstart' in window || navigator.msMaxTouchPoints) || false | ||
export default ('ontouchstart' in window || navigator.msMaxTouchPoints) || false |
@@ -1,1 +0,1 @@ | ||
export default supportTransform = 'webkitTransform' in document.body.style || 'transform' in document.body.style; | ||
export default 'webkitTransform' in document.body.style || 'transform' in document.body.style; |
@@ -1,1 +0,1 @@ | ||
export default supportTransition = 'webkitTransition' in document.body.style || 'transition' in document.body.style; | ||
export default 'webkitTransition' in document.body.style || 'transition' in document.body.style; |
@@ -1,3 +0,3 @@ | ||
export default function addClass(element,classNAME) { | ||
export default function(element,classNAME) { | ||
element.classList.add(classNAME) | ||
} |
@@ -1,3 +0,3 @@ | ||
export default function hasClass(element,classNAME) { | ||
export default function(element,classNAME) { | ||
return element.classList.contains(classNAME) | ||
} |
@@ -1,3 +0,3 @@ | ||
export default function removeClass(element,classNAME) { | ||
export default function(element,classNAME) { | ||
element.classList.remove(classNAME) | ||
} |
// detach handlers | ||
export default function off (element, event, handler, options) { | ||
export default function(element, event, handler, options) { | ||
options = options || false; | ||
element.removeEventListener(event, handler, options); | ||
} |
// attach handlers | ||
export default function on (element, event, handler, options) { | ||
export default function(element, event, handler, options) { | ||
options = options || false; | ||
element.addEventListener(event, handler, options); | ||
} |
@@ -5,3 +5,3 @@ import on from './on.js' | ||
// attach & detach handlers | ||
export default function one (element, event, handler, options) { | ||
export default function(element, event, handler, options) { | ||
on(element, event, function handlerWrapper(e){ | ||
@@ -8,0 +8,0 @@ if (e.target === element) { |
@@ -6,3 +6,3 @@ // import one from '../event/one.js'; | ||
// emulateTransitionEnd | ||
export default function emulateTransitionEnd (element,handler){ | ||
export default function(element,handler){ | ||
let called = 0, duration = getElementTransitionDuration(element); | ||
@@ -9,0 +9,0 @@ duration ? element.addEventListener( transitionEndEvent, function transitionEndWrapper(e){ |
import supportTransition from '../boolean/supportTransition.js'; | ||
import transitionDuration from '../strings/transitionDuration.js'; | ||
export default function getElementTransitionDuration (element) { | ||
export default function(element) { | ||
let duration = supportTransition ? parseFloat(getComputedStyle(element)[transitionDuration]) : 0; | ||
@@ -6,0 +6,0 @@ duration = typeof duration === 'number' && !isNaN(duration) ? duration * 1000 : 0; |
@@ -1,2 +0,2 @@ | ||
export default function isElementInScrollRange(element) { | ||
export default function(element) { | ||
let bcr = element.getBoundingClientRect(), | ||
@@ -3,0 +3,0 @@ viewportHeight = window.innerHeight || document.documentElement.clientHeight; |
// check if element is in viewport | ||
export default function isElementInViewport(element) { | ||
export default function(element) { | ||
var bcr = element.getBoundingClientRect(); | ||
@@ -4,0 +4,0 @@ return ( |
@@ -6,2 +6,2 @@ // general event options | ||
export default passiveHandler = supportPassive ? { passive: true } : false | ||
export default supportPassive ? { passive: true } : false |
@@ -1,4 +0,4 @@ | ||
export default function queryElement (selector, parent) { | ||
export default function(selector, parent) { | ||
var lookUp = parent && parent instanceof Element ? parent : document; | ||
return selector instanceof Element ? selector : lookUp.querySelector(selector); | ||
} |
@@ -1,2 +0,2 @@ | ||
export default function tryWrapper (fn,origin){ | ||
export default function(fn,origin){ | ||
try{ fn() } | ||
@@ -3,0 +3,0 @@ catch(e){ |
@@ -1,1 +0,1 @@ | ||
export default mouseClickEvents = { down: 'mousedown', up: 'mouseup' } | ||
export default { down: 'mousedown', up: 'mouseup' } |
@@ -1,1 +0,1 @@ | ||
export default mouseHoverEvents = ('onmouseleave' in document) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ] | ||
export default ('onmouseleave' in document) ? [ 'mouseenter', 'mouseleave'] : [ 'mouseover', 'mouseout' ] |
@@ -1,1 +0,1 @@ | ||
export default mouseSwipeEvents = { start: 'mousedown', end: 'mouseup', move:'mousemove', cancel:'mouseout' } | ||
export default { start: 'mousedown', end: 'mouseup', move:'mousemove', cancel:'mouseout' } |
@@ -1,1 +0,1 @@ | ||
export default touchEvents = { start: 'touchstart', end: 'touchend', move:'touchmove', cancel:'touchcancel' } | ||
export default { start: 'touchstart', end: 'touchend', move:'touchmove', cancel:'touchcancel' } |
@@ -1,1 +0,1 @@ | ||
export default transitionDuration = 'webkitTransition' in document.body.style ? 'webkitTransitionDuration' : 'transitionDuration'; | ||
export default 'webkitTransition' in document.body.style ? 'webkitTransitionDuration' : 'transitionDuration'; |
@@ -1,1 +0,1 @@ | ||
export default transitionEndEvent = 'webkitTransition' in document.body.style ? 'webkitTransitionEnd' : 'transitionend'; | ||
export default 'webkitTransition' in document.body.style ? 'webkitTransitionEnd' : 'transitionend'; |
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
30381
409