Skip to content

BaggersIO/angular.throttle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular.throttle

This extension enables throttling for AngularJS. This is useful to tear down fast iterative events, like window.resize.

Installation

bower install angular-throttle
<script type="bower_components/angular-throttle/src/angular.throttle.js"></script>

Usage

// Declares a throttled function
// This function will be invoked by a minimum of 250 ms
var throttledResize = angular.throttle(function () {

    console.log('No browser drain at each event please.');

}, 250);

angular.element(window).on('resize', throttledResize);

Options

You can use some options:

angular.throttle(fn, delay, {
	leading: false,
	trailing: false
})

options.leading If leading is true the function will be invoked at the startup. Otherwise not. Default true.

options.trailing When trailing is set to false the function will not be invoked the end of the operation. Default true

The extension was inspired by UnderscoreJS so you are able to use the same options.

License

Do what you want.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published