Git Product home page Git Product logo

jquery-breakpoint-check's Introduction

jQuery Bootstrap 3 Breakpoint Check

Check the current visibility of bootstrap 3 breakpoints.

Why another breakpoint check for bootstrap 3?

The plugin I have created for simple reasons:

  • I needed something that works and is easy to integrate into existing projects (in my daily work)
  • I did not want to create a new code in each project. A plugin repository is mostly stable
  • Bootstrap did not provide its own Javascript API for this
  • I had fun doing it^^

Installation

You can download the plugin manually or install by composer. ... and the plugin requires jQuery. ;) jQuery must be properly integrated into the page.

Install via Composer (recommended for php projects)

If you do not have Composer, you may install it by following the instructions at getcomposer.org.

You can then install the package using the following command:

php composer.phar require --prefer-dist cakebake/jquery-breakpoint-check "*"

or add

"cakebake/jquery-breakpoint-check": "*"

to the require section of your composer.json file and run php composer.phar update.

Manual Installation

Download:

Include one of the two javascript files from the folder js after jQuery include. For productive projects, you can use the jquery-breakpoint-check.min.js version. For more details see file test.html.

Example:

<script src="js/jquery-breakpoint-check.min.js"></script>

Usage

Is the current screen resolution xs breakpoint?

if ($.isXs()) {
    alert('Is xs breakpoint :)');
}

Is the current screen resolution sm breakpoint?

if ($.isSm()) {
    alert('Is sm breakpoint :)');
}

Is the current screen resolution md breakpoint?

if ($.isMd()) {
    alert('Is md :)');
}

Is the current screen resolution lg breakpoint?

if ($.isLg()) {
    alert('Is lg breakpoint :)');
}

Is the current screen resolution custom breakpoint?

Create a CSS-Class with visibility for your custom breakpoint. For example:

.visible-grid-float-breakpoint {
    @media (min-width: @grid-float-breakpoint-max) {
        display: none;
        visibility: hidden;
    }
}
if ($.isBreakpoint('grid-float-breakpoint')) {
    alert('It is my custom breakpoint :)');
}

Check the current breakpoint on screen resize.

$(window).resize(function () {
    if ($.isXs()) {
        alert('Is xs breakpoint :)');
    } else if ($.isSm()) {
        alert('Is sm breakpoint :)');
    } else if ($.isMd()) {
        alert('Is md :)');
    } else if ($.isLg()) {
        alert('Is lg breakpoint :)');
    }
}).resize();

Hide a div on xs and lg breakpoint.

$(window).resize(function () {
    var selector = $("div.selector");
    if ($.isXs() || $.isLg()) {
        selector.hide();
    } else {
        selector.hide();
    }
}).resize();

Copyright and License

Copyright (C) Jens A. (cakebake)

Released under the MIT license

jquery-breakpoint-check's People

Contributors

cakebake avatar miguelmich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jquery-breakpoint-check's Issues

Bower package

Hello @cakebake ,

Just wanted to let you know that I just registered the bower package of your repository in order to make releases available from bower.

To install this repo with bower use bower install jquery-breakpoint-check If you want to update your documentation :)

PD: Thanks for this awesome and clean work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.