Skip to content

Nimbleworks/css-breakpoint.jquery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

css-breakpoint.jquery

Detect the current breakpoint defined by your media queries and load callbacks for when the breakpoint changes.

The script reads the body:after content attribute of the html document. You will need to define this in your main stylesheets for each of your breakpoints. With media queries you can switch between stylesheets and therefore the body:after declaration. This is what the script detects.

##Usage

Insert the following rule into any stylesheet you want to detect, changing the content attribute to the key you would like to use.

body:after {
    content: 'basic';
    display: none;
}

Using media queries to switch between stylesheets, you will be able to detect which one is active in JavaScript using the following methods:

service.breakpoint()

Returns the key used in the content attribute (see above) in the currently active stylesheet.

service.breakpoint((string) key)

Returns a boolean. True if the key of the currently active stylesheet matches the string supplied as an argument.

service.service.onBreakpointChange((function) callback)

Adds a callback function. If the breakpoint changes when the browser window is resized then this function will be called.

About

Detect the current breakpoint defined by your media queries and load callbacks for when the breakpoint changes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published