Skip to content

Instantly share code, notes, and snippets.

@sethblanchard
Created June 25, 2015 18:01
Show Gist options
  • Save sethblanchard/ed4c81a7d8677a35ccdd to your computer and use it in GitHub Desktop.
Save sethblanchard/ed4c81a7d8677a35ccdd to your computer and use it in GitHub Desktop.
Initial idea for debounce with request animation frame
_ticking = false;
function onResize() {
requestTick();
}
/**
* Calls rAF if it's not already
* been done already
*/
function requestTick() {
if(!_ticking) { //Figure out someway to queue setTimeout callback fixes
requestAnimationFrame(batchActions);
_ticking = true;
}
}
var batchActions = function(superTimeStamp){
//Before running expensive function
// 1. wait ?
// 2. compare window sizes until user stops resizing
if(1 && 2){
//run expensive
_ticking = false;
}
};
window.addEventListener('resize', onResize, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment