vue-screen
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -39,36 +39,2 @@ 'use strict'; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
var inBrowser = typeof window !== 'undefined'; | ||
@@ -338,3 +304,3 @@ var debounce = function debounce(callback, wait) { | ||
delete breakpoints.extend; | ||
return _objectSpread({}, breakpoints, Plugin.getBreakpoints(framework)); | ||
return Object.assign({}, breakpoints, Plugin.getBreakpoints(framework)); | ||
} | ||
@@ -341,0 +307,0 @@ |
@@ -1,1 +0,1 @@ | ||
var VueScreen=function(){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e){var t=e.split("."),n=parseInt(t[0],10);return{major:"number"==typeof n?n:1,minor:parseInt(t[1],10)||0,patch:parseInt(t[2],10)||0}}var o,c="undefined"!=typeof window,t={bootstrap:{sm:576,md:768,lg:992,xl:1200},bulma:{tablet:769,desktop:1024,widescreen:1216,fullhd:1408},foundation:{medium:640,large:1024},"semantic-ui":{tablet:768,computer:992,large:1201},tailwind:{sm:576,md:768,lg:992,xl:1200}},s="2.6.0",u=["width","height","touch","portrait","landscape"],e=function(){function n(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this.callbacks={},this.createScreen(n.parseBreakpoints(e)),this.init()}return function(e,t,n){t&&i(e.prototype,t),n&&i(e,n)}(n,[{key:"init",value:function(){this.attachResize(),this.setScreenSize(),this.checkTouch()}},{key:"attachResize",value:function(){c&&window.addEventListener("resize",function(n,r){var i;return function(){var e=this,t=arguments;clearTimeout(i),i=setTimeout(function(){i=null,n.apply(e,t)},r)}}(this.setScreenSize.bind(this),100))}},{key:"setScreenSize",value:function(){c&&(this.screen.width=window.innerWidth,this.screen.height=window.innerHeight,this.runCallbacks())}},{key:"runCallbacks",value:function(){var t=this;Object.keys(this.callbacks).forEach(function(e){t.screen[e]=t.callbacks[e].call(null,t.screen)})}},{key:"checkTouch",value:function(){c&&(this.screen.touch="ontouchstart"in window)}},{key:"createScreen",value:function(e){var t=this;this.screen=o.observable({width:410,height:730,touch:!0,portrait:!0,landscape:!1}),Object.keys(e).forEach(function(e){if(0<=u.indexOf(e))throw new Error('Invalid breakpoint name: "'.concat(e,'". This key is reserved.'));o.set(t.screen,e,!1)}),c&&this.initMediaQueries(e)}},{key:"initMediaQueries",value:function(i){var a=this;Object.keys(i).forEach(function(t){var e=i[t],n=null;if("function"==typeof e?a.callbacks[t]=e:n="number"==typeof e?"".concat(e,"px"):e,n){var r=window.matchMedia("(min-width: ".concat(n,")"));r.addListener(function(e){return a.mediaStateChanged(t,e.matches)}),a.mediaStateChanged(t,r.matches)}});var e=window.matchMedia("(orientation: portrait)");e.addListener(function(e){a.mediaStateChanged("portrait",e.matches),a.mediaStateChanged("landscape",!e.matches)}),this.mediaStateChanged("portrait",e.matches),this.mediaStateChanged("landscape",!e.matches)}},{key:"mediaStateChanged",value:function(e,t){o.set(this.screen,e,t)}}],[{key:"parseBreakpoints",value:function(e){if("object"!==r(e))return n.getBreakpoints(e.toString());if(e.extend){var t=e.extend.toString();return delete e.extend,function(i){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{},t=Object.keys(a);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable}))),t.forEach(function(e){var t,n,r;t=i,r=a[n=e],n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r})}return i}({},e,n.getBreakpoints(t))}return e}},{key:"getBreakpoints",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";if(e||(e="tailwind"),!t[e])throw new Error('Cannot find grid breakpoints for framework "'.concat(e,'"'));return t[e]}},{key:"install",value:function(e,t){if(!function(e,t){var n=a(e),r=a(t);return n.major>r.major||n.major===r.major&&n.minor>r.minor||n.major===r.major&&n.minor===r.minor&&n.patch>=r.patch}((o=e).version,s))throw Error("VueScreen requires at least Vue ".concat(s));o.prototype.$screen=new n(t).screen}}]),n}();return c&&window.Vue&&window.Vue.use(e),e}(); | ||
var VueScreen=function(){"use strict";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function r(e){var t=e.split("."),n=parseInt(t[0],10);return{major:"number"==typeof n?n:1,minor:parseInt(t[1],10)||0,patch:parseInt(t[2],10)||0}}var o,c="undefined"!=typeof window,t={bootstrap:{sm:576,md:768,lg:992,xl:1200},bulma:{tablet:769,desktop:1024,widescreen:1216,fullhd:1408},foundation:{medium:640,large:1024},"semantic-ui":{tablet:768,computer:992,large:1201},tailwind:{sm:576,md:768,lg:992,xl:1200}},s="2.6.0",u=["width","height","touch","portrait","landscape"],e=function(){function n(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this.callbacks={},this.createScreen(n.parseBreakpoints(e)),this.init()}return function(e,t,n){t&&a(e.prototype,t),n&&a(e,n)}(n,[{key:"init",value:function(){this.attachResize(),this.setScreenSize(),this.checkTouch()}},{key:"attachResize",value:function(){c&&window.addEventListener("resize",function(n,i){var a;return function(){var e=this,t=arguments;clearTimeout(a),a=setTimeout(function(){a=null,n.apply(e,t)},i)}}(this.setScreenSize.bind(this),100))}},{key:"setScreenSize",value:function(){c&&(this.screen.width=window.innerWidth,this.screen.height=window.innerHeight,this.runCallbacks())}},{key:"runCallbacks",value:function(){var t=this;Object.keys(this.callbacks).forEach(function(e){t.screen[e]=t.callbacks[e].call(null,t.screen)})}},{key:"checkTouch",value:function(){c&&(this.screen.touch="ontouchstart"in window)}},{key:"createScreen",value:function(e){var t=this;this.screen=o.observable({width:410,height:730,touch:!0,portrait:!0,landscape:!1}),Object.keys(e).forEach(function(e){if(0<=u.indexOf(e))throw new Error('Invalid breakpoint name: "'.concat(e,'". This key is reserved.'));o.set(t.screen,e,!1)}),c&&this.initMediaQueries(e)}},{key:"initMediaQueries",value:function(a){var r=this;Object.keys(a).forEach(function(t){var e=a[t],n=null;if("function"==typeof e?r.callbacks[t]=e:n="number"==typeof e?"".concat(e,"px"):e,n){var i=window.matchMedia("(min-width: ".concat(n,")"));i.addListener(function(e){return r.mediaStateChanged(t,e.matches)}),r.mediaStateChanged(t,i.matches)}});var e=window.matchMedia("(orientation: portrait)");e.addListener(function(e){r.mediaStateChanged("portrait",e.matches),r.mediaStateChanged("landscape",!e.matches)}),this.mediaStateChanged("portrait",e.matches),this.mediaStateChanged("landscape",!e.matches)}},{key:"mediaStateChanged",value:function(e,t){o.set(this.screen,e,t)}}],[{key:"parseBreakpoints",value:function(e){if("object"!==i(e))return n.getBreakpoints(e.toString());if(e.extend){var t=e.extend.toString();return delete e.extend,Object.assign({},e,n.getBreakpoints(t))}return e}},{key:"getBreakpoints",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";if(e||(e="tailwind"),!t[e])throw new Error('Cannot find grid breakpoints for framework "'.concat(e,'"'));return t[e]}},{key:"install",value:function(e,t){if(!function(e,t){var n=r(e),i=r(t);return n.major>i.major||n.major===i.major&&n.minor>i.minor||n.major===i.major&&n.minor===i.minor&&n.patch>=i.patch}((o=e).version,s))throw Error("VueScreen requires at least Vue ".concat(s));o.prototype.$screen=new n(t).screen}}]),n}();return c&&window.Vue&&window.Vue.use(e),e}(); |
{ | ||
"name": "vue-screen", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Reactive window size and media query states for Vue components. Integrates with most UI frameworks.", | ||
@@ -5,0 +5,0 @@ "keywords": ["vuejs", "window", "reactive window", "media query", "matchMedia", "innerWidth", "innerHeight"], |
@@ -102,3 +102,3 @@ [](https://badge.fury.io/js/vue-screen) | ||
To use callbacks togheter with breakpoints from one of the supported UI frameworks you can specify the `extend` property: | ||
To use callbacks together with breakpoints from one of the supported UI frameworks you can specify the `extend` property: | ||
@@ -105,0 +105,0 @@ ```js |
@@ -52,6 +52,7 @@ import { debounce, inBrowser, checkVersion } from './utils'; | ||
return { | ||
...breakpoints, | ||
...Plugin.getBreakpoints(framework), | ||
}; | ||
return Object.assign( | ||
{}, | ||
breakpoints, | ||
Plugin.getBreakpoints(framework) | ||
); | ||
} | ||
@@ -58,0 +59,0 @@ |
Sorry, the diff of this file is not supported yet
229760
2141