-
Notifications
You must be signed in to change notification settings - Fork 0
isBreakpoint
Mike Byrne edited this page Jan 25, 2022
·
7 revisions
Checks if the current breakpoint matches the passed breakpoint. Breakpoints are hardcoded to the common A17 Boilerplate sizes - xsmall, small, medium, large, xlarge, xxlarge. It supports querying with or without the +/- modifiers.
Returns the current media query in use by looking at the font-family of the head of the document and text in pseudo content on the body. Useful for running JS functions at certain breakpoints without holding breakpoint size information in CSS and JS.
You can override the default breakpoints using the breakpoints property on the global A17 object in app.js.
- bp - required - the breakpoint to match current breakpoint against
- boolean
// returns true (if viewport is 'medium' size)
var isMediumViewport = isBreakpoint('medium');
// returns true (if viewport is 'large', 'xlarge' or 'xxlarge' size)
var isLargerViewport = isBreakpoint('large+');
// returns true (if viewport is 'small' or 'xsmall' size)
var isSmallerViewport = isBreakpoint('small-');// app.js
// override default breakpoints (optional)
var A17 = window.A17 || {};
A17.breakpoints = [ 'small', 'medium', 'large' ];