js-media-query
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,2 +0,2 @@ | ||
var t={xs:0,sm:576,md:768,lg:992,xl:1200},n=function(n){var e=this;void 0===n&&(n=t),this.breakpoints=t,this.events={in:[],out:[],changed:[]},this.media=function(t){return window.matchMedia(t).matches},this.query=function(t){return e.media(t)},this.min=function(t){return e.query("(min-width: "+t+"px)")},this.max=function(t){return e.query("(max-width: "+t+"px)")},this.up=function(t){return e.min(t)},this.down=function(t){return e.max(t)},this.between=function(t,n){return e.query("(min-width: "+t+"px) and (max-width: "+n+"px)")},this.isTouch=function(){return e.query("(pointer: coarse)")},this.isMouse=function(){return e.query("(pointer: fine)")},this.xs=function(){return e.up(e.breakpoints.xs)},this.sm=function(){return e.up(e.breakpoints.sm)},this.md=function(){return e.up(e.breakpoints.md)},this.lg=function(){return e.up(e.breakpoints.lg)},this.xl=function(){return e.up(e.breakpoints.xl)},this.on=function(t,n,i){n instanceof Function&&e.events[t].push({media:i,callback:n,value:i()}),e.initEvents()},this.off=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=t[0],r=t[1],s=t[2];e.events[i]=void 0===r?[]:e.events[i].filter(void 0===s?function(t){return!(t.callback===r)}:function(t){return!(t.callback===r&&t.media===s)}),e.initEvents()},this.resize=function(){for(var t in e.events)for(var n=0,i=e.events[t];n<i.length;n+=1){var r=i[n],s=r.media();r.value!==s&&("changed"===t?r.callback():"in"===t?!0===s&&r.callback():"out"===t&&!1===s&&r.callback(),r.value=s)}},this.initEvents=function(){for(var t in e.events)if(e.events[t].length)return void window.addEventListener("resize",function(){e.resize()});window.removeEventListener("resize",e.resize)},this.setBreakpoints(n)};n.prototype.setBreakpoints=function(t){this.breakpoints={xs:t.xs,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl}};var e=new n,i=e.query,r=e.min,s=e.max,o=e.up,u=e.down,a=e.between,c=e.isTouch,h=e.isMouse,p=e.xs,f=e.sm,l=e.md,d=e.lg,m=e.xl,v=e.setBreakpoints,x={xs:0,sm:576,md:768,lg:992,xl:1200},k=function(t){var n=this;void 0===t&&(t=x),this.breakpoints=x,this.events={in:[],out:[],changed:[]},this.media=function(t){return window.matchMedia(t).matches},this.query=function(t){return n.media(t)},this.min=function(t){return n.query("(min-width: "+t+"px)")},this.max=function(t){return n.query("(max-width: "+t+"px)")},this.up=function(t){return n.min(t)},this.down=function(t){return n.max(t)},this.between=function(t,e){return n.query("(min-width: "+t+"px) and (max-width: "+e+"px)")},this.isTouch=function(){return n.query("(pointer: coarse)")},this.isMouse=function(){return n.query("(pointer: fine)")},this.xs=function(){return n.up(n.breakpoints.xs)},this.sm=function(){return n.up(n.breakpoints.sm)},this.md=function(){return n.up(n.breakpoints.md)},this.lg=function(){return n.up(n.breakpoints.lg)},this.xl=function(){return n.up(n.breakpoints.xl)},this.on=function(t,e,i){e instanceof Function&&n.events[t].push({media:i,callback:e,value:i()}),n.initEvents()},this.off=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var i=t[0],r=t[1],s=t[2];n.events[i]=void 0===r?[]:n.events[i].filter(void 0===s?function(t){return!(t.callback===r)}:function(t){return!(t.callback===r&&t.media===s)}),n.initEvents()},this.resize=function(){for(var t in n.events)for(var e=0,i=n.events[t];e<i.length;e+=1){var r=i[e],s=r.media();r.value!==s&&("changed"===t?r.callback():"in"===t?!0===s&&r.callback():"out"===t&&!1===s&&r.callback(),r.value=s)}},this.initEvents=function(){for(var t in n.events)if(n.events[t].length)return void window.addEventListener("resize",function(){n.resize()});window.removeEventListener("resize",n.resize)},this.setBreakpoints(t)};k.prototype.setBreakpoints=function(t){this.breakpoints={xs:t.xs,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl}};var b=new k;exports.default=b,exports.Media=n,exports.query=i,exports.min=r,exports.max=s,exports.up=o,exports.down=u,exports.between=a,exports.isTouch=c,exports.isMouse=h,exports.xs=p,exports.sm=f,exports.md=l,exports.lg=d,exports.xl=m,exports.setBreakpoints=v; | ||
function t(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,i=new Array(n);e<n;e++)i[e]=t[e];return i}function n(n,e){var i;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(i=function(n,e){if(n){if("string"==typeof n)return t(n,void 0);var i=Object.prototype.toString.call(n).slice(8,-1);return"Object"===i&&n.constructor&&(i=n.constructor.name),"Map"===i||"Set"===i?Array.from(n):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(n,void 0):void 0}}(n))||e&&n&&"number"==typeof n.length){i&&(n=i);var r=0;return function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(i=n[Symbol.iterator]()).next.bind(i)}var e={xs:0,sm:576,md:768,lg:992,xl:1200},i=function(){function t(t){var i=this,r=this;void 0===t&&(t=e),this.breakpoints=e,this.events={in:[],out:[],changed:[]},this.media=function(t){return window.matchMedia(t).matches},this.query=function(t){return i.media(t)},this.min=function(t){return i.query("(min-width: "+t+"px)")},this.max=function(t){return i.query("(max-width: "+t+"px)")},this.up=function(t){return i.min(t)},this.down=function(t){return i.max(t)},this.between=function(t,n){return i.query("(min-width: "+t+"px) and (max-width: "+n+"px)")},this.isTouch=function(){return i.query("(pointer: coarse)")},this.isMouse=function(){return i.query("(pointer: fine)")},this.xs=function(){return i.up(i.breakpoints.xs)},this.sm=function(){return i.up(i.breakpoints.sm)},this.md=function(){return i.up(i.breakpoints.md)},this.lg=function(){return i.up(i.breakpoints.lg)},this.xl=function(){return i.up(i.breakpoints.xl)},this.on=function(t,n,e){n instanceof Function&&i.events[t].push({media:e,callback:n,value:e()}),i.initEvents()},this.off=function(){var t=[].slice.call(arguments),n=t[0],e=t[1],i=t[2];r.events[n]=void 0===e?[]:r.events[n].filter(void 0===i?function(t){return!(t.callback===e)}:function(t){return!(t.callback===e&&t.media===i)}),r.initEvents()},this.resize=function(){for(var t in i.events)for(var e,r=n(i.events[t]);!(e=r()).done;){var s=e.value,o=s.media();s.value!==o&&("changed"===t?s.callback():"in"===t?!0===o&&s.callback():"out"===t&&!1===o&&s.callback(),s.value=o)}},this.initEvents=function(){for(var t in i.events)if(i.events[t].length)return void window.addEventListener("resize",function(){i.resize()});window.removeEventListener("resize",i.resize)},this.setBreakpoints(t)}return t.prototype.setBreakpoints=function(t){this.breakpoints={xs:t.xs,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl}},t}(),r=new i,s=r.query,o=r.min,u=r.max,a=r.up,c=r.down,l=r.between,f=r.isTouch,h=r.isMouse,p=r.xs,d=r.sm,m=r.md,v=r.lg,x=r.xl,b=r.setBreakpoints,w={xs:0,sm:576,md:768,lg:992,xl:1200},k=new(function(){function t(t){var e=this,i=this;void 0===t&&(t=w),this.breakpoints=w,this.events={in:[],out:[],changed:[]},this.media=function(t){return window.matchMedia(t).matches},this.query=function(t){return e.media(t)},this.min=function(t){return e.query("(min-width: "+t+"px)")},this.max=function(t){return e.query("(max-width: "+t+"px)")},this.up=function(t){return e.min(t)},this.down=function(t){return e.max(t)},this.between=function(t,n){return e.query("(min-width: "+t+"px) and (max-width: "+n+"px)")},this.isTouch=function(){return e.query("(pointer: coarse)")},this.isMouse=function(){return e.query("(pointer: fine)")},this.xs=function(){return e.up(e.breakpoints.xs)},this.sm=function(){return e.up(e.breakpoints.sm)},this.md=function(){return e.up(e.breakpoints.md)},this.lg=function(){return e.up(e.breakpoints.lg)},this.xl=function(){return e.up(e.breakpoints.xl)},this.on=function(t,n,i){n instanceof Function&&e.events[t].push({media:i,callback:n,value:i()}),e.initEvents()},this.off=function(){var t=[].slice.call(arguments),n=t[0],e=t[1],r=t[2];i.events[n]=void 0===e?[]:i.events[n].filter(void 0===r?function(t){return!(t.callback===e)}:function(t){return!(t.callback===e&&t.media===r)}),i.initEvents()},this.resize=function(){for(var t in e.events)for(var i,r=n(e.events[t]);!(i=r()).done;){var s=i.value,o=s.media();s.value!==o&&("changed"===t?s.callback():"in"===t?!0===o&&s.callback():"out"===t&&!1===o&&s.callback(),s.value=o)}},this.initEvents=function(){for(var t in e.events)if(e.events[t].length)return void window.addEventListener("resize",function(){e.resize()});window.removeEventListener("resize",e.resize)},this.setBreakpoints(t)}return t.prototype.setBreakpoints=function(t){this.breakpoints={xs:t.xs,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl}},t}());exports.Media=i,exports.between=l,exports.default=k,exports.down=c,exports.isMouse=h,exports.isTouch=f,exports.lg=v,exports.max=u,exports.md=m,exports.min=o,exports.query=s,exports.setBreakpoints=b,exports.sm=d,exports.up=a,exports.xl=x,exports.xs=p; | ||
//# sourceMappingURL=media.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.jsMediaQuery={})}(this,function(n){var t={xs:0,sm:576,md:768,lg:992,xl:1200},e=function(n){var e=this;void 0===n&&(n=t),this.breakpoints=t,this.events={in:[],out:[],changed:[]},this.media=function(n){return window.matchMedia(n).matches},this.query=function(n){return e.media(n)},this.min=function(n){return e.query("(min-width: "+n+"px)")},this.max=function(n){return e.query("(max-width: "+n+"px)")},this.up=function(n){return e.min(n)},this.down=function(n){return e.max(n)},this.between=function(n,t){return e.query("(min-width: "+n+"px) and (max-width: "+t+"px)")},this.isTouch=function(){return e.query("(pointer: coarse)")},this.isMouse=function(){return e.query("(pointer: fine)")},this.xs=function(){return e.up(e.breakpoints.xs)},this.sm=function(){return e.up(e.breakpoints.sm)},this.md=function(){return e.up(e.breakpoints.md)},this.lg=function(){return e.up(e.breakpoints.lg)},this.xl=function(){return e.up(e.breakpoints.xl)},this.on=function(n,t,i){t instanceof Function&&e.events[n].push({media:i,callback:t,value:i()}),e.initEvents()},this.off=function(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];var i=n[0],r=n[1],s=n[2];e.events[i]=void 0===r?[]:e.events[i].filter(void 0===s?function(n){return!(n.callback===r)}:function(n){return!(n.callback===r&&n.media===s)}),e.initEvents()},this.resize=function(){for(var n in e.events)for(var t=0,i=e.events[n];t<i.length;t+=1){var r=i[t],s=r.media();r.value!==s&&("changed"===n?r.callback():"in"===n?!0===s&&r.callback():"out"===n&&!1===s&&r.callback(),r.value=s)}},this.initEvents=function(){for(var n in e.events)if(e.events[n].length)return void window.addEventListener("resize",function(){e.resize()});window.removeEventListener("resize",e.resize)},this.setBreakpoints(n)};e.prototype.setBreakpoints=function(n){this.breakpoints={xs:n.xs,sm:n.sm,md:n.md,lg:n.lg,xl:n.xl}};var i=new e,r=i.query,s=i.min,u=i.max,o=i.up,a=i.down,c=i.between,f=i.isTouch,h=i.isMouse,d=i.xs,l=i.sm,m=i.md,v=i.lg,p=i.xl,x=i.setBreakpoints,k={xs:0,sm:576,md:768,lg:992,xl:1200},b=function(n){var t=this;void 0===n&&(n=k),this.breakpoints=k,this.events={in:[],out:[],changed:[]},this.media=function(n){return window.matchMedia(n).matches},this.query=function(n){return t.media(n)},this.min=function(n){return t.query("(min-width: "+n+"px)")},this.max=function(n){return t.query("(max-width: "+n+"px)")},this.up=function(n){return t.min(n)},this.down=function(n){return t.max(n)},this.between=function(n,e){return t.query("(min-width: "+n+"px) and (max-width: "+e+"px)")},this.isTouch=function(){return t.query("(pointer: coarse)")},this.isMouse=function(){return t.query("(pointer: fine)")},this.xs=function(){return t.up(t.breakpoints.xs)},this.sm=function(){return t.up(t.breakpoints.sm)},this.md=function(){return t.up(t.breakpoints.md)},this.lg=function(){return t.up(t.breakpoints.lg)},this.xl=function(){return t.up(t.breakpoints.xl)},this.on=function(n,e,i){e instanceof Function&&t.events[n].push({media:i,callback:e,value:i()}),t.initEvents()},this.off=function(){for(var n=[],e=arguments.length;e--;)n[e]=arguments[e];var i=n[0],r=n[1],s=n[2];t.events[i]=void 0===r?[]:t.events[i].filter(void 0===s?function(n){return!(n.callback===r)}:function(n){return!(n.callback===r&&n.media===s)}),t.initEvents()},this.resize=function(){for(var n in t.events)for(var e=0,i=t.events[n];e<i.length;e+=1){var r=i[e],s=r.media();r.value!==s&&("changed"===n?r.callback():"in"===n?!0===s&&r.callback():"out"===n&&!1===s&&r.callback(),r.value=s)}},this.initEvents=function(){for(var n in t.events)if(t.events[n].length)return void window.addEventListener("resize",function(){t.resize()});window.removeEventListener("resize",t.resize)},this.setBreakpoints(n)};b.prototype.setBreakpoints=function(n){this.breakpoints={xs:n.xs,sm:n.sm,md:n.md,lg:n.lg,xl:n.xl}};var w=new b;n.default=w,n.Media=e,n.query=r,n.min=s,n.max=u,n.up=o,n.down=a,n.between=c,n.isTouch=f,n.isMouse=h,n.xs=d,n.sm=l,n.md=m,n.lg=v,n.xl=p,n.setBreakpoints=x}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).jsMediaQuery={})}(this,function(n){function t(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,i=new Array(t);e<t;e++)i[e]=n[e];return i}function e(n,e){var i;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(i=function(n,e){if(n){if("string"==typeof n)return t(n,void 0);var i=Object.prototype.toString.call(n).slice(8,-1);return"Object"===i&&n.constructor&&(i=n.constructor.name),"Map"===i||"Set"===i?Array.from(n):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(n,void 0):void 0}}(n))||e&&n&&"number"==typeof n.length){i&&(n=i);var r=0;return function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(i=n[Symbol.iterator]()).next.bind(i)}var i={xs:0,sm:576,md:768,lg:992,xl:1200},r=function(){function n(n){var t=this,r=this;void 0===n&&(n=i),this.breakpoints=i,this.events={in:[],out:[],changed:[]},this.media=function(n){return window.matchMedia(n).matches},this.query=function(n){return t.media(n)},this.min=function(n){return t.query("(min-width: "+n+"px)")},this.max=function(n){return t.query("(max-width: "+n+"px)")},this.up=function(n){return t.min(n)},this.down=function(n){return t.max(n)},this.between=function(n,e){return t.query("(min-width: "+n+"px) and (max-width: "+e+"px)")},this.isTouch=function(){return t.query("(pointer: coarse)")},this.isMouse=function(){return t.query("(pointer: fine)")},this.xs=function(){return t.up(t.breakpoints.xs)},this.sm=function(){return t.up(t.breakpoints.sm)},this.md=function(){return t.up(t.breakpoints.md)},this.lg=function(){return t.up(t.breakpoints.lg)},this.xl=function(){return t.up(t.breakpoints.xl)},this.on=function(n,e,i){e instanceof Function&&t.events[n].push({media:i,callback:e,value:i()}),t.initEvents()},this.off=function(){var n=[].slice.call(arguments),t=n[0],e=n[1],i=n[2];r.events[t]=void 0===e?[]:r.events[t].filter(void 0===i?function(n){return!(n.callback===e)}:function(n){return!(n.callback===e&&n.media===i)}),r.initEvents()},this.resize=function(){for(var n in t.events)for(var i,r=e(t.events[n]);!(i=r()).done;){var o=i.value,s=o.media();o.value!==s&&("changed"===n?o.callback():"in"===n?!0===s&&o.callback():"out"===n&&!1===s&&o.callback(),o.value=s)}},this.initEvents=function(){for(var n in t.events)if(t.events[n].length)return void window.addEventListener("resize",function(){t.resize()});window.removeEventListener("resize",t.resize)},this.setBreakpoints(n)}return n.prototype.setBreakpoints=function(n){this.breakpoints={xs:n.xs,sm:n.sm,md:n.md,lg:n.lg,xl:n.xl}},n}(),o=new r,s=o.query,u=o.min,a=o.max,c=o.up,f=o.down,l=o.between,d=o.isTouch,h=o.isMouse,m=o.xs,p=o.sm,v=o.md,x=o.lg,b=o.xl,y=o.setBreakpoints,w={xs:0,sm:576,md:768,lg:992,xl:1200},k=new(function(){function n(n){var t=this,i=this;void 0===n&&(n=w),this.breakpoints=w,this.events={in:[],out:[],changed:[]},this.media=function(n){return window.matchMedia(n).matches},this.query=function(n){return t.media(n)},this.min=function(n){return t.query("(min-width: "+n+"px)")},this.max=function(n){return t.query("(max-width: "+n+"px)")},this.up=function(n){return t.min(n)},this.down=function(n){return t.max(n)},this.between=function(n,e){return t.query("(min-width: "+n+"px) and (max-width: "+e+"px)")},this.isTouch=function(){return t.query("(pointer: coarse)")},this.isMouse=function(){return t.query("(pointer: fine)")},this.xs=function(){return t.up(t.breakpoints.xs)},this.sm=function(){return t.up(t.breakpoints.sm)},this.md=function(){return t.up(t.breakpoints.md)},this.lg=function(){return t.up(t.breakpoints.lg)},this.xl=function(){return t.up(t.breakpoints.xl)},this.on=function(n,e,i){e instanceof Function&&t.events[n].push({media:i,callback:e,value:i()}),t.initEvents()},this.off=function(){var n=[].slice.call(arguments),t=n[0],e=n[1],r=n[2];i.events[t]=void 0===e?[]:i.events[t].filter(void 0===r?function(n){return!(n.callback===e)}:function(n){return!(n.callback===e&&n.media===r)}),i.initEvents()},this.resize=function(){for(var n in t.events)for(var i,r=e(t.events[n]);!(i=r()).done;){var o=i.value,s=o.media();o.value!==s&&("changed"===n?o.callback():"in"===n?!0===s&&o.callback():"out"===n&&!1===s&&o.callback(),o.value=s)}},this.initEvents=function(){for(var n in t.events)if(t.events[n].length)return void window.addEventListener("resize",function(){t.resize()});window.removeEventListener("resize",t.resize)},this.setBreakpoints(n)}return n.prototype.setBreakpoints=function(n){this.breakpoints={xs:n.xs,sm:n.sm,md:n.md,lg:n.lg,xl:n.xl}},n}());n.Media=r,n.between=l,n.default=k,n.down=f,n.isMouse=h,n.isTouch=d,n.lg=x,n.max=a,n.md=v,n.min=u,n.query=s,n.setBreakpoints=y,n.sm=p,n.up=c,n.xl=b,n.xs=m}); | ||
//# sourceMappingURL=media.umd.js.map |
{ | ||
"name": "js-media-query", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "CSS Media query in js", | ||
@@ -10,2 +10,3 @@ "source": "src/index.ts", | ||
"unpkg": "dist/media.umd.js", | ||
"types": "dist/Media/index.d.ts", | ||
"scripts": { | ||
@@ -27,5 +28,5 @@ "build": "microbundle build src/index.ts", | ||
"devDependencies": { | ||
"microbundle": "^0.11.0" | ||
"microbundle": "^0.12.0" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -189,7 +189,7 @@ interface IBreapoints { | ||
this.events[event] = this.events[event].filter( | ||
mediaEvent => !(mediaEvent.callback === callback), | ||
(mediaEvent) => !(mediaEvent.callback === callback), | ||
); | ||
} else { | ||
this.events[event] = this.events[event].filter( | ||
mediaEvent => | ||
(mediaEvent) => | ||
!(mediaEvent.callback === callback && mediaEvent.media === media), | ||
@@ -204,3 +204,3 @@ ); | ||
for (const eventType in this.events) { | ||
const events: MediaEvent[] = this.events[eventType]; | ||
const events: MediaEvent[] = this.events[eventType as MediaEventType]; | ||
for (const event of events) { | ||
@@ -230,3 +230,3 @@ const value = event.media(); | ||
for (const eventType in this.events) { | ||
if (this.events[eventType].length) { | ||
if (this.events[eventType as MediaEventType].length) { | ||
window.addEventListener("resize", () => { | ||
@@ -233,0 +233,0 @@ this.resize(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances 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
205855
21
448
2