2011-11-15 5 views
1

をホバーボタンをは継続的に私は、ナビゲーションボタンを推移しているときは常に連続してスクロールするカルーセルを必要とする...私はjCarouselプラグインを使用していると私は、道路のバンプを打ってきた

をjCarouselをスクロールします。組み込みの設定変数を "mouseover"に変更すると、ホバー一回だけスクロールします。

私はthis similar questionに出くわしましたが、私はjavascriptのエキスパートではなく、答えを得ることができません。すべてのヘルプははるかに高く評価されるだろう

function mycarousel_initCallback(carousel) 
{ 

    // Pause autoscrolling if the user moves with the cursor over the clip. 
    carousel.clip.hover(function() { 
     carousel.stopAuto(); 
    }, function() { 
     carousel.startAuto(); 
    }); 
}; 

jQuery(document).ready(function() { 
    jQuery('#mycarousel').jcarousel({ 
     auto: 10, 
     start: 1, 
     scroll: 1, 
     animation: 'slow', 
     wrap: 'circular', 
     buttonNextEvent: 'mouseover', 
     buttonPrevEvent: 'mouseover', 
     initCallback: mycarousel_initCallback 
    }); 
}); 

は、ここに私のコードです。

答えて

4

次のスクリプトを使用して動作させることができます。私はそれをテストしましたjquery.jcarousel.jsjquery-1.4.1

私のjcarouselの設定には自動スクロールがありませんでした。

<script> 
jQuery(document).ready(function() { 
    var _this = null; 
    $('.jcarousel-next').mouseover(function() { 
     if (!$(this).hasClass("jcarousel-next-disabled")) { 
      _this = $(this); 
      _this.click(); 
      window.setTimeout(CallAgain, 100); 
     } 
    }); 

    $('.jcarousel-next').mouseout(function() { 
     if (!$(this).hasClass("jcarousel-next-disabled")) { 
      _this = null; 
     } 
    }); 

    function CallAgain() { 
     if (_this != null) { 
      //alert("Inside Call again"); 
      _this.click(); 
      window.setTimeout(CallAgain, 100); 
     } 
    }; 

    $('.jcarousel-prev').mouseover(function() { 
     if (!jQuery(this).hasClass("jcarousel-prev-disabled")){ 
      _this = $(this); 
      _this.click(); 
      window.setTimeout(CallAgain, 100); 
     } 
    }); 

    $('.jcarousel-prev').mouseout(function() { 
     if (!$(this).hasClass("jcarousel-next-disabled")) { 
      _this = null; 
     } 
    }); 
}); 
</script> 
+0

ここで、カルーセルが表示されている.htmlファイルにこのスクリプトを挿入しますか?さらに、 'buttonNextEvent'と 'buttonPrevEvent'は 'mouseover'ではなく 'click'に設定する必要がありますか? –

関連する問題