Created
December 12, 2012 11:48
-
-
Save pocotan001/4267194 to your computer and use it in GitHub Desktop.
値の更新を待つscrollToのラッパー(for Android)
This file contains hidden or 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
/** | |
* 値の更新を待つ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