Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var processor = {
- timeoutId:null,
- performProcessoring:function(){
- // do something
- },
- process:function(){
- clearTimeout(this.timeoutId);
- var that = this;
- this.timeoutId = setTimeout(function(){
- that.performProcessoring();
- },100)
- }
- }
- /** throttle**/
- function throttle(method,context){
- clearTimeout(method.tId);
- method.tId = setTimeout(function(){
- method.call(context);
- },100)
- }
- //example
- function resizeDiv(){
- }
- window.onresize = function(){
- throttle(resizeDiv)
- }
Add Comment
Please, Sign In to add comment