jQuery Plugin To Fire Events When The Window Hits Specific Breakpoints - Glassjs

jQuery Plugin To Fire Events When The Window Hits Specific Breakpoints - Glassjs
File Size: 5.95 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Glassjs is a tiny and cross-browser jQuery plugin which handles window resize event and fires events when the browser hits specific breakpoints.

See also:

How to use it:

1. Load the jQuery Glassjs plugin's script after loading jQuery library.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="src/glass.js"></script>

2. Initialize the plugin and override the default breakpoints you prefer.

glass({
  'sm': [0, 767],
  'med': [768, 1023],
  'lrg': [1024]
});

3. Fire events once the window reaches the breakpoints you specify.

var $win = $(window);

$win.on('glass.sm', function() {
  // do something
});

$win.on('glass.med', function() {
  // do something
});

$win.on('glass.lrg', function() {
  // do something
});

This awesome jQuery plugin is developed by derekborland. For more Advanced Usages, please check the demo page or visit the official website.