Files
ionic-framework/core/src/utils/media.ts
Manu MA 34dfc3ce98 refactor(all): updating to newest stencil apis (#18578)
* chore(): update ionicons

* refactor(all): updating to newest stencil apis

* fix lint issues

* more changes

* moreee

* fix treeshaking

* fix config

* fix checkbox

* fix stuff

* chore(): update ionicons

* fix linting errors
2019-06-23 11:26:42 +02:00

23 lines
633 B
TypeScript

export const SIZE_TO_MEDIA: any = {
'xs': '(min-width: 0px)',
'sm': '(min-width: 576px)',
'md': '(min-width: 768px)',
'lg': '(min-width: 992px)',
'xl': '(min-width: 1200px)',
};
// Check if the window matches the media query
// at the breakpoint passed
// e.g. matchBreakpoint('sm') => true if screen width exceeds 576px
export function matchBreakpoint(breakpoint: string | undefined) {
if (breakpoint === undefined || breakpoint === '') {
return true;
}
if ((window as any).matchMedia) {
const mediaQuery = SIZE_TO_MEDIA[breakpoint];
return window.matchMedia(mediaQuery).matches;
}
return false;
}