JavaScript はマルチスレッド化されていないため、上記のコードは機能しません。つまり、while ループが CPU を消費しており、他のコードの実行を妨げている可能性があります (つまり、mouseup イベント)。
私は少し前にこのようなことをしました。私のブログ投稿をチェックしてください。
また、これを行っているかどうかはわかりませんが、すべての JavaScript コードを jQuery の ready() 関数に配置してください。そうしないと、jQuery が #scUp 要素を見つけられない可能性があります。
私の古いブログ投稿からの関連コードは次のとおりです。
var scrollTimer;
function scrollContent(amt)
{
$("#content").scrollTop($("#content").scrollTop()+amt);
scrollTimer = window.setTimeout("scrollContent(" + amt + ")", 25);
}
$(document).ready(function ()
{
$("#content").css("overflow", "hidden");
$("#scrollUp").mousedown(function() {
window.clearTimeout(scrollTimer); //Not necessary, but just to be sure...
$("#scrollUp").animate({"opacity": 100}, 'fast');
scrollContent(-10);
});
$("#scrollUp").mouseup(function() {
window.clearTimeout(scrollTimer);
$("#scrollUp").animate({"opacity": 0}, 'fast');
});
$("#scrollDown").mousedown(function() {
window.clearTimeout(scrollTimer); //Not necessary, but just to be sure...
$("#scrollDown").animate({"opacity": 100}, 'fast');
scrollContent(10);
});
$("#scrollDown").mouseup(function() {
window.clearTimeout(scrollTimer);
$("#scrollDown").animate({"opacity": 0}, 'fast');
});
//$("#scrollUp").css("opacity", 0); //Alternative
$("#scrollUp").animate({"opacity": 0}, 'slow');
$("#scrollDown").animate({"opacity": 0}, 'slow');
});
...そしてリンク:
http://blake-miner.blogspot.com/2010/08/javascript-sticky-footer-and-scroll.html
お役に立てれば!