Javascript 在Prototype UI中将循环滚动添加到我的旋转木马
我有一个旋转木马,滚动很好,但是当它到达内容的末尾(Javascript 在Prototype UI中将循环滚动添加到我的旋转木马,javascript,user-interface,prototypejs,Javascript,User Interface,Prototypejs,我有一个旋转木马,滚动很好,但是当它到达内容的末尾()时,它就停止了。我想从头再来 这里是我的代码,我已经蹒跚在一起,不好用JavaScript等 <script type="text/javascript"> function startscroll() { x = window.setInterval(function scroll() { hCarousel.scrollTo(hCarousel.currentIndex() + 3); },3
)时,它就停止了。我想从头再来
这里是我的代码,我已经蹒跚在一起,不好用JavaScript等
<script type="text/javascript">
function startscroll() {
x = window.setInterval(function scroll() {
hCarousel.scrollTo(hCarousel.currentIndex() + 3);
},3000);
}
function stopscroll() {
window.clearInterval(x);
}
function runTest() {
hCarousel = new UI.Carousel("horizontal_carousel", {direction: "horizontal"});
startscroll();
$('horizontal_carousel').observe('mouseover', stopscroll);
$('horizontal_carousel').observe('mouseout', startscroll);
}
Event.observe(window, "load", runTest);
</script>
函数startscroll(){
x=window.setInterval(函数滚动(){
hCarousel.scrollTo(hCarousel.currentIndex()+3);
},3000);
}
函数stopscroll(){
窗口。清除间隔(x);
}
函数runTest(){
hCarousel=newui.Carousel(“水平旋转木马”{方向:“水平”});
startscroll();
$(“水平旋转木马”)。观察('mouseover',停止滚动);
$('horizontal_carousel')。观察('mouseout',startscroll);
}
观察事件(窗口“加载”,运行测试);
谢谢你的帮助
戴夫。改变这个
$('horizontal_carousel')。观察('mouseover',stopscroll);
$('horizontal_carousel')。观察('mouseout',startscroll)代码>
到
$('horizontal_carousel').onmouseover = function(){
stopscroll();
}
$('horizontal_carousel').onmouseout = function(){
startscroll();
}`