Check if element is visible on screenまたはCheck if element is visible after scrollingのようなものが必要な場合があります。つまり、要素のトップオフセットが画面の境界内にあるかどうかを確認し、その条件が満たされている場合はアニメーションを開始します。
var theElementInQuestion = document.getElementById("theElementInQuestion");
if (isScrolledIntoView(theElementInQuestion)) {
startAnimation();
}
function isScrolledIntoView(elem)
{
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
あなたのページをリンクするのではなく、コードを投稿することができれば簡単です。このようにして、問題が解決された後であっても、あなたの問題と解決策を理解することができます。このサイトはプロジェクト用ではなく、質問用です。 –