簡體   English   中英

使用下一個/上一個按鈕在我現有的滑塊中添加導航項目符號

[英]adding navigation bullets in my existing slider with next / previous button

我有一個帶有下一個/上一個按鈕的簡單視頻滑塊。 事實證明,每個視頻幻燈片都需要單獨的項目符號導航。

這給我帶來了與你們的問候。

這是我可憐的努力,以證明我的所作所為:

的HTML

<div class="container row full-content" style="position: relative  !important; top: -180px !important;">


      <div class="right-side full-content col-xs-3 down">
    <div class="slide-box">


        <div class="example1" id="start1">

          <video  id="video1" class="example1" width="240" height="134" controls autoplay true>
                <source src="./files/videos/video-1.mp4" type="video/mp4">
          </video>
          <div style="clear:float ;height: 10px;"></div>
          <span class="presented">Presented by: </span>
          <a href="#" class="presenter black">First Presenter</a>
          <span class="slide-count">Slide <strong>1 of 6</strong></span> 
        </div>




      <div class="example1">
            <video  class="example1" width="240" height="134" controls  false>
              <source src="./files/videos/video-3.mp4" type="video/mp4">
            </video>

        <div style="clear:float ;height: 10px;"></div><span class="presented">Presented by: </span><a href="#" class="presenter black">Presentation 2</a>
        <span class="slide-count">Slide <strong>2 of 6</strong></span> 
      </div>

      <div class="example1">
            <video  class="example1" width="240" height="134" controls  false>
              <source src="./files/videos/presenter-4.mp4" type="video/mp4">
            </video>

        <div style="clear:float ;height: 10px;"></div><span class="presented">Presented by: </span><a href="#" class="presenter black">Presenter Name</a>
        <span class="slide-count">Slide <strong>3 of 6</strong></span> 
      </div>

      <div class="example1">
            <video  class="example1" width="240" height="134" controls  false>
              <source src="./files/videos/presenter-5.mp4" type="video/mp4">
            </video>

        <div style="clear:float ;height: 10px;"></div><span class="presented">Presented by: </span><a href="#" class="presenter black">Presenter Name</a>
        <span class="slide-count">Slide <strong>4 of 6</strong></span> 
      </div>

      <div class="example1">
            <video  class="example1" width="240" height="134" controls  false>
              <source src="./files/videos/presenter-6.mp4" type="video/mp4">
            </video>

        <div style="clear:float ;height: 10px;"></div><span class="presented">Presented by: </span><a href="#" class="presenter black">Presenter Name</a>
        <span class="slide-count">Slide <strong>5 of 6</strong></span> 
      </div>


      <div class="example1">
            <video  class="example1" width="240" height="134" controls  false>
              <source src="./files/videos/presenter-7.mp4" type="video/mp4">
            </video>

        <div style="clear:float ;height: 10px;"></div><span class="presented">Presented by: </span><a href="#" class="presenter black">Presenter Name</a>
        <span class="slide-count">Slide <strong>6 of 6</strong></span> 
      </div>


          <br/>
          <ul class="pagination vertical" style="position: relative; top: -30px;">
        <a href="#" class="back">
            <li class="float-left"><img src="./images/previous-button.png"/></li>
            </a> <a href="#" class="forward">
            <li class="float-right"><img src="./images/next-button.png"/></li>
            </a>
      </ul>
        </div>
    <a class="presentation-buttons down select" href="#" data-toggle="modal" data-target="#myModal">Select presentation slide</a> 

<a class="presentation-buttons down select" href="#" data-toggle="modal" data-target="#myModal2">View presentation menu</a> 


 </div>

</div>

jQuery查詢

$(document).ready(function(e) {


    var $curr = $( "#start" );

    var slide_index = 1;
    var max_slides = $("div.slide-image").children("div.example").length;

    /* Video Navigation JS */

    var $curr1 = $( "#start1" );
    $curr1.css(  "height" , "" );

    var video_index = 1;
    var max_videos = $("div.slide-box").children("div.example1").length;

    next_img = './sites/all/themes/basic/images/next-button.png';
    ds_next_img = './sites/all/themes/basic/images/disabled-next.png';

    previous_img = './sites/all/themes/basic/images/previous-button.png';
    ds_previous_img = './sites/all/themes/basic/images/disabled-previous.png';


     $('li.float-left img').attr("src", ds_previous_img);
    //alert(max_videos);

    $( ".back" ).click(function() {

      if (video_index - 1 < 1) {
         $('li.float-left img').attr("src", ds_previous_img);
        return;
      }

      $('li.float-right img').attr("src", next_img);


      $curr1.children('video.example1').get(0).pause();
      $curr1 = $curr1.prev();

      video_index --;

      if (video_index - 1 < 1) {
        $('li.float-left img').attr("src", ds_previous_img);
      }


      var styles = {
          display: "block"
        };

        var default_styles = {
          display: "none"
        };
      $( "div.example1" ).css( default_styles );
      $curr1.css( styles );

      $curr1.children('video.example1').get(0).play();
    });


    $( ".forward" ).click(function() {


      if (video_index +1 > max_videos) {

        $('li.float-right img').attr("src", ds_next_img);
        return;
      }

      $('li.float-left img').attr("src", previous_img);

      $curr1.children('video.example1').get(0).pause();

      $curr1 = $curr1.next();

      video_index ++;

      if (video_index +1 > max_videos) {
        $('li.float-right img').attr("src", ds_next_img);
      }



      var styles = {
            display: "block"
          };

          var default_styles = {
            display: "none"
          };
        $( "div.example1" ).css( default_styles );
        $curr1.css( styles );

        //$curr1.children('video').play();
        $curr1.children('video.example1').get(0).play();
        //$curr1.children('video').attr({'autoplay':'true'});


      });


    });

這就是我做的。

在此處輸入鏈接說明

最好。

function showSlide(id){ // id is the variable name of what we will be calling which will be passed
    stopLoop(); // call function that we have declared above so that the interval is cleared and restarted

        if(id > count){
            id = 1; // if id = more than the count of images then set back to 1
        }else if(id < 1){
            id = count; // if id = less than count of list then set back to 4 or whatever number of images
        }

        $('.quickslider > img').fadeOut(300); // fadeout all images
        $('.quickslider > img#'+id).fadeIn(300); // use sliderNext to calculate the next slider id

        $('.nav-thumbs > a#'+id).addClass('active');

        sliderInt = id; // update so that the current slide = 2 as set globally
        sliderNext = id + 1; // calculate the next image
        startSlider(); // start the slider process again, as it was stopped before
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM