Created
June 25, 2015 18:01
-
-
Save sethblanchard/ed4c81a7d8677a35ccdd to your computer and use it in GitHub Desktop.
Initial idea for debounce with request animation frame
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
_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