Created
June 9, 2014 13:38
-
-
Save luobotang/f12b879a223f37cdc127 to your computer and use it in GitHub Desktop.
AutoScroll
This file contains 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
// 自动滚动 | |
// div#demo style:overflow:hidden | |
// div#demo1 | |
// div#demo2 | |
var SPEED = 60, | |
demo2 = document.getElementById("demo2"), | |
demo1 = document.getElementById("demo1"), | |
demo = document.getElementById("demo"); | |
function Marquee() { | |
// demo1 显示完毕之后重新切换显示 demo1 | |
if (demo.scrollTop >= demo2.offsetTop) { | |
demo.scrollTop -= demo1.offsetHeight; | |
} else { | |
demo.scrollTop++; | |
} | |
} | |
demo2.innerHTML = demo1.innerHTML; | |
var MyMar = setInterval(Marquee, SPEED); | |
demo.onmouseover=function() { clearInterval(MyMar); } | |
demo.onmouseout=function() {MyMar = setInterval(Marquee, SPEED); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment