iScrollのドキュメントには、次のような一般的なiScrollの設定が示されています。
var myScroll;
function loaded() {
setTimeout(function () {
myScroll = new iScroll('wrapper');
}, 100);
}
window.addEventListener('load', loaded, false);
私の質問は、どのようにスクローラーを呼び出すのですか?私が使用する場合:
var currentItem = 5;
myScroll.scrollToElement('.nav > li:nth-child('+currentItem+')', 300);
エラーが発生します。
Uncaught TypeError: Cannot call method 'scrollToElement' of undefined