Skip to content

Instantly share code, notes, and snippets.

@pocotan001
Created December 12, 2012 11:48
Show Gist options
  • Save pocotan001/4267194 to your computer and use it in GitHub Desktop.
Save pocotan001/4267194 to your computer and use it in GitHub Desktop.
値の更新を待つscrollToのラッパー(for Android)
/**
* 値の更新を待つscrollToのラッパー(for Android)
*
* @param {Number} x
* @param {Number} y
* @param {[Function]} callback
*/
function setScrollTo(x, y, callback) {
var body = document.body;
(function polling() {
if(x === body.scrollLeft && y === body.scrollTop) {
if (typeof callback === 'function') callback();
} else {
setTimeout(polling, 10);
}
})();
window.scrollTo(x, y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment