Skip to content

adding a $(window).on('breakpointChange') event useable with e.g. for bootstrap layouts

License

Notifications You must be signed in to change notification settings

Matthias-Hermsdorf/breakpointChange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

breakpointChange

breakpointChange triggers a breakpointChange Event at the window object when the screensize changes and breakpoints where crossed. It requires jQuery and was developed for boostrap templates, when some modules are active only on special screensizes.

    $(window).on("breakpointChange", function (e) {
        if (e.newBreakpoint == "sm") {
            console.log("you are now between 0 and 1011 px screenwith");
        }
        else {
            console.log("a big screen you have, young padawan");
        }
    });

You can change the breakpoints with breakpointChange.breakpoints at runtime The breakpoints must be sorted ascending. Following breakpoints are default:

breakpointChange.breakpoints = {
            "sm": 0,
            "md": 1011,
            "lg": 1199
        }

The breapointChange event contains the keys for newBreakpoint, oldBreakpoint, the originalEvent which triggert the Change and some jQuery event information.

    {
        "newBreakpoint":newBreakpoint, 
        "oldBreakpoint":overridenBreakpoint, 
        "originalEvent":e
    }

breakpointChange.getCurrentBreakpoint() returns the current breakpoint

About

adding a $(window).on('breakpointChange') event useable with e.g. for bootstrap layouts

Resources

License

Stars

Watchers

Forks

Packages

No packages published