Skip to content

Instantly share code, notes, and snippets.

@barneycarroll
Created March 26, 2013 12:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save barneycarroll/5245137 to your computer and use it in GitHub Desktop.
Save barneycarroll/5245137 to your computer and use it in GitHub Desktop.
Javascript to emulate media queries with event firing and HTML class toggling to avoid duplication, conflict & waste in native CSS implementation + JS feature dependency. Public version of a private gist created 2012-09-13T11:34:06Z
/* 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