Skip to content

Instantly share code, notes, and snippets.

@bnoden
Created January 20, 2018 09:54
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 bnoden/0c5072885919306d0adbd67ac2dedcea to your computer and use it in GitHub Desktop.
Save bnoden/0c5072885919306d0adbd67ac2dedcea to your computer and use it in GitHub Desktop.
const maintainPosition = () => {
let prevHeight = document.body.clientHeight;
setInterval((x, y) => {
if (prevHeight !== document.body.clientHeight) {
x = window.scrollX;
y = window.scrollY + document.body.clientHeight - prevHeight;
window.scrollTo(x, y);
}
}, 100);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment