Prototype.js news scrollerが公開されてたのでPrototypeLessにしてみた。
イベントハンドラ部分
<div style="height:250px" onmouseover='stopScroll=1' onmouseout='stopScroll=0;scrollMe()' id="highlights" class="highlights">
prototype.jsはIDへのショートカットにしか使用しってなかったので。
無駄な記述も多かったかな。
var h = document.getElementById('highlights');
var repeatHeight = h.scrollHeight //get the current height so we know when to wrap
h.innerHTML += h.innerHTML //add a second copy so we can scroll down to the wrap point
var stopScroll = 0
var x = setTimeout("scrollMe()",1000)
function scrollMe() {
clearTimeout(x)
if(stopScroll==1)return
h.scrollTop++
if(h.scrollTop>repeatHeight)h.scrollTop=0
x = setTimeout("scrollMe()",40)
}
スポンサードリンク
javascriptに関するエントリー
メールで購読する
twitterで購読する
RSSで購読する
コメントする