Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 832 Bytes

README.md

File metadata and controls

39 lines (30 loc) · 832 Bytes

jquery-throttle

jQuery plugin for requestAnimationFrame based event throttling

Availability

bower install jquery-throttle

Installation

<script src="bower_components/requestAnimationFrame.js/requestAnimationFrame.js"></script>
<script src="bower_components/jquery-throttle/jquery.throttle.js"></script>

Usage

Use in the same way as you would use jQuery's .on() and .off():

$(window).throttle("resize", function() {
    // your code here
});
$(window).removeThrottle("resize");

If you're developing a plugin, check if jquery.throttle is available, and fallback to jQuery.on().

if (typeof($(window).throttle) == "function") {
    $(window).throttle("resize", function() {
        // your code here
    });
}
else {
    $(window).on("resize", onResize);
}