Created
May 31, 2020 13:22
-
-
Save eiskalteschatten/7e22105d6cd9e6ea37c05b0c80aadd6d to your computer and use it in GitHub Desktop.
A small script to determine viewport widths based on Bootstrap breakpoints.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// View port widths from Bootstrap | |
export const xs = 0; | |
export const sm = 576; | |
export const md = 768; | |
export const lg = 992; | |
export const xl = 1200; | |
export const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); | |
export const isSmDown = (): boolean => vw <= sm; | |
export const isMdDown = (): boolean => vw <= md; | |
export const isLgDown = (): boolean => vw <= lg; | |
export const isSmUp = (): boolean => vw >= sm; | |
export const isMdUp = (): boolean => vw >= md; | |
export const isLgUp = (): boolean => vw >= lg; | |
export const isXs = (): boolean => vw <= xs; | |
export const isSm = (): boolean => vw >= sm && vw < md; | |
export const isMd = (): boolean => vw >= md && vw < lg; | |
export const isLg = (): boolean => vw >= lg && vw < xl; | |
export const isXl = (): boolean => vw >= xl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment