jQuery Plugin To Fire Events On Window Resize - Respond

File Size: 6.03 KB
Views Total: 593
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin To Fire Events On Window Resize - Respond

Respond.js is a super simple jQuery plugin for mobile & responsive development that automatically detects browser resizing and fires events when the windows's size reaches a specified breakpoint (xs, sm, md, lg).

See also:

How to use it:

1. Import the jQuery respond.js plugin into the document. Be sure that you first have jQuery library installed.

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="src/respond.js"></script>

2. Basic usage.

var onFunctions = {
    on: {
      is: {
        xs: function(){console.log('is xs')},
        sm: function(){console.log('is sm')},
        md: function(){console.log('is md')},
        lg: function(){console.log('is lg')}
      },
      was: {
        xs: function(){console.log('was xs')},
        sm: function(){console.log('was sm')},
        md: function(){console.log('was md')},
        lg: function(){console.log('was lg')}
      }
    }
};

$(document).ready(
  function() {
    $.respond({functions:onFunctions});
  }
);

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