Skip to content

Instantly share code, notes, and snippets.

@rossPatton
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossPatton/1fc476950f95dc5b9b09 to your computer and use it in GitHub Desktop.
Save rossPatton/1fc476950f95dc5b9b09 to your computer and use it in GitHub Desktop.
Scroll like a king
module.exports = function domUpdate( app ): Object {
if ( typeof app !== 'object' ) { return; }
// recursion recursion recursion
// we pass in the FSB stuff to make sure we're
// using the latest cache stuff
raf(() => {
return app.domUpdate( app );
});
let cache: Object = app.cache;
// dont move me. i go before the early return.
// visual perf gets killed if i move
cache.currScroll = window.pageYOffset + 60;
// exit early if possible and do no work (if not moving basically)
if ( cache.currScroll === cache.prevScroll ) {
return;
}
/*
do
your
logic
here
*/
cache.prevScroll = window.pageYOffset + 60;
return cache;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment