2

我正在使用 jQUery FlexSlider 以下是我的代码

<link rel="stylesheet" type="text/css" href="css/gallery/shCore.css" />
<link rel="stylesheet" type="text/css" href="css/gallery/shThemeDefault.css" />
<link rel="stylesheet" type="text/css" href="css/gallery/flexslider.css" />

<script type="text/javascript" src="js/gallery/modernizr.js"></script>
<script type="text/javascript" src="js/gallery/jquery.flexslider.js" ></script>
<script type="text/javascript" src="js/gallery/shCore.js"></script> 
<script type="text/javascript" src="js/gallery/shBrushXml.js"></script>
<script type="text/javascript" src="js/gallery/shBrushJScript.js"></script>

<script type="text/javascript" src="js/gallery/jquery.easing.js"></script>
<script type="text/javascript" src="js/gallery/jquery.mousewheel.js"></script>

和下面的 isin 身体

<body>
<div id="slider" class="flexslider">
                      <ul class="slides">
                             <li >
                              <img src="images/gallery/1.jpg" alt="image01" data-description="Fiesta Gallery" height="299px" width="450px" /> 
                            </li>
                            <li >
                              <img src="images/gallery/2.jpg" alt="image01" data-description="Fiesta Gallery" height="299px" width="450px"/> 
                            </li>
                            <li >
                              <img src="images/gallery/3.jpg" alt="image01" data-description="Fiesta Gallery" height="299px" width="450px" /> 
                            </li>
                            <li >
                              <img src="images/gallery/4.jpg" alt="image01" data-description="Fiesta Gallery" height="299px" width="450px" /> 
                            </li>   
                            <li >
                              <img src="images/gallery/5.jpg" alt="image01" data-description="Fiesta Gallery" height="299px" width="450px" /> 
                            </li>
                            <li >
                              <img src="images/gallery/6.jpg" alt="image93" data-description="Fiesta Gallery" height="299px" width="450px" />
                            </li>
                            <li >
                              <img src="images/gallery/7.jpg" alt="image97" data-description="Fiesta Gallery" height="299px" width="450px" />
                            </li>
                            <li >
                              <img src="images/gallery/8.jpg" alt="image108" data-description="Fiesta Gallery" height="299px" width="450px" />
                            </li>
</ul>
                    </div>
                    <div id="carousel" class="flexslider" style="margin-top:-50px;">
                      <ul class="slides">
                            <li >
                              <img src="images/gallery/thumbs/1.jpg" height="100px"  /> 
                            </li>
                            <li >
                              <img src="images/gallery/thumbs/2.jpg" height="100px" /> 
                            </li>
                            <li >
                              <img src="images/gallery/thumbs/3.jpg" height="100px" /> 
                            </li>
                            <li >
                              <img src="images/gallery/thumbs/4.jpg" height="100px" /> 
                            </li>       
                            <li >
                              <img src="images/gallery/thumbs/5.jpg"  height="100px" /> 
                            </li>
                            <li >
                              <img src="images/gallery/thumbs/6.jpg" height="100px" />
                            </li>
                            <li >
                              <img src="images/gallery/thumbs/7.jpg" height="100px" />
                            </li>
                            <li >
                              <img src="images/gallery/thumbs/8.jpg" height="100px" />
                            </li>
</ul>
                    </div>
</body>

以下是head部分的配置

$(function(){
      SyntaxHighlighter.all();
    });
    $(window).load(function() {
      // The slider being synced must be initialized first
      $('#carousel').flexslider({
        animation: "slide",
        controlNav: false,
        animationLoop: true,
        directionNav: false,
        slideshow: false,       
        slideshowSpeed: 7500,
        animationSpeed: 400,   
        itemWidth: 150,
        itemMargin: 5,
        startAt: 0, 
        move : 3,             
        asNavFor: '#slider'

      });

      $('#slider').flexslider({
        animation: "slide",
        controlNav: false,
        animationLoop: true,
        slideshowSpeed: 7500,
        animationSpeed: 400,
        pauseOnAction: false,
        slideshow: true,
        startAt: 0, 
        sync: "#carousel",
        start: function(slider) {
        $('#carousel .slides li img').click(function(event){
            event.preventDefault();
            //slider.flexAnimate(slider.getTarget("next"));
            var count = slider.currentSlide + 1;
            slider.flexAnimate(count);
        });
        }
      });
    });

从上面的代码中,我可以进行自动滑动、左/右按钮导航,并且在一些缩略图中单击它可以工作。

但是如果我点击当前缩略图后面的两个缩略图,它会停止自动滑动。

我怎样才能解决这个问题?任何帮助将不胜感激。

提前感谢!!

4

2 回答 2

6

我用以下代码替换:它有效

start: function(slider) {
    $('#carousel .slides li img').click(function(event){
        $('#slider').flexslider("play");
    });
}

我可以从参考中弄清楚: https ://github.com/woothemes/FlexSlider/

于 2012-07-30T14:27:53.130 回答
0

这是HTML结构

             <div class="g-s-wrapper">

              <div class="flexslider">

                <ul class="slides">

                  <li data-thumb="assets/img/gallery-photo/1.jpg">
                    <img src="assets/img/gallery-photo/1.jpg" alt="">
                  </li>

                  <li data-thumb="assets/img/gallery-photo/2.jpg">
                    <img src="assets/img/gallery-photo/2.jpg" alt="">
                  </li>

                </ul> <!-- .slides -->

              </div>  <!-- .flexslider -->

            </div>  <!-- .gallery slider wrapper -->

当你调用 flexslider 函数时,使用如下

    if ($('.g-s-wrapper').length > 0) {

    $(window).load(function () {
        $('.g-s-wrapper .flexslider').flexslider({
            slideshowSpeed: 2000,
            directionNav: false, 
            controlNav: true,
            start: function(){
                var slide_li = $('.g-s-wrapper ul.slides li').not('.clone');
                var control_li = $('.g-s-wrapper .flexslider .flex-control-nav li a');
                console.log(control_li);
                $.each(slide_li, function(index, el){
                    var img_src = $('<img src="" />').attr('src', $(el).attr('data-thumb'));
                                img_src.appendTo(control_li[index]);

                });                             
            }   
        });
    });
于 2015-09-02T02:30:48.263 回答