在Prototype UI中将循环滚动添加到我的旋转木马中

Add looping scroll to my carousel in Prototype-UI

本文关键字:添加 我的 旋转木马 滚动 循环 Prototype UI      更新时间:2023-09-26

我有一个旋转木马,它可以很好地滚动,但当它到达内容(<li>.</li>)的末尾时,它就会停止。我希望它能从头开始。

这是我的代码,我已经蹒跚而行,因为不擅长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>

谢谢你的帮助戴夫。

更改此

$('horizontal_carousel').observe('mouseover', stopscroll); $('horizontal_carousel').observe('mouseout', startscroll);

  $('horizontal_carousel').onmouseover = function(){
stopscroll();
}
        $('horizontal_carousel').onmouseout = function(){
startscroll();
}`