Skip to content

Instantly share code, notes, and snippets.

@svenoaks
Forked from barneycarroll/mediaJQuery.css
Last active August 29, 2015 14:07
Show Gist options
  • Save svenoaks/fd204fb4cf17cda5ed45 to your computer and use it in GitHub Desktop.
Save svenoaks/fd204fb4cf17cda5ed45 to your computer and use it in GitHub Desktop.
/* Javascript to emulate media queries with events and HTML class toggling
* to avoid duplication, conflict & waste when implemented via
* native CSS implementation + JS feature dependency.
*
* Depends on jQuery and Cowboy's throttle / debounce plugin:
* https://github.com/cowboy/jquery-throttle-debounce
*/
(function(){
var options = {
rateLimitMethod : ['debounce','throttle']
};
var defaults = {
events : 'resize',
rateLimitMethod : 'throttle',
rateLimitDelay : 60
};
var config = $.extend({}, defaults);
$(window).on(events, $[rateLimitMethod](rateLimitDelay), fn);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment