-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreakpoints.min.js
More file actions
1 lines (1 loc) · 872 Bytes
/
breakpoints.min.js
File metadata and controls
1 lines (1 loc) · 872 Bytes
1
var breakpoints=function(){"use strict";return class{constructor(t){this.config=t||[["xs",0],["sm",480],["md",768],["lg",1024],["xl",1280],["x2",1440],["x3",1690],["x4",1920],["x5",2560]],this.b={},this.n={},this.w=0}setValues(){this.w=window.innerWidth,this.config.forEach(((t,s,i)=>{let e=t[0],h=t[1],n=this.w;if(void 0!==i[s+1]){let t=i[s+1][1];this.n[e]=h,this.b[e]=h<=n&&n<t}else this.n[e]=h,this.b[e]=h<=n}))}getKeyByValue(t,s){return Object.keys(t).find((i=>t[i]===s))}lte(t){return this.setValues(),void 0!==this.n[t]&&(this.w<=this.n[t]||this.b[t])}gte(t){return void 0!==this.n[t]&&(this.setValues(),this.w>=this.n[t])}is(t){return void 0!==this.n[t]&&(this.setValues(),this.b[t])}get(){return this.setValues(),this.getKeyByValue(this.b,!0)}between(t,s){return void 0!==this.n[t]&&void 0!==this.n[s]&&(this.setValues(),this.n[t]<=this.w&&this.w<=this.n[s])}}}();