Created
March 26, 2013 12:52
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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