Горизонтальная полоса прокрутки базы предметов - PullRequest
0 голосов
/ 19 апреля 2019

Я хочу создать пункт меню горизонтальной прокрутки в меню начальной загрузки. У меня есть код сценария Java для прокрутки горизонтального меню, когда окно маленькое. но проблема в том, что

<nav class="navbar navbar-inverse event_nav menu_mobile">
      <div class="container-fluid">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>                        
              </button>
            </div>

            <div class="collapse navbar-collapse" id="myNavbar">
              <ul class="nav navbar-nav">
                <li class = "<?php if($currentPage =='event_detail'){echo 'active';}?>">
                        <a href="event_detail.php">Event Details</a>
                </li>
                <li class = "<?php if($currentPage =='spk'){echo 'active';}?>">
                    <a href="spk.php">Speakers</a>
                </li>
                <li class = "<?php if($currentPage =='partner'){echo 'active';}?>">
                    <a href="partner.php">Partners</a>
                </li>
                <li class = "<?php if($currentPage =='venu'){echo 'active';}?>">
                    <a href="venu.php">Venue</a>
                </li>
                <li class = "<?php if($currentPage =='Agenda'){echo 'active';}?>">
                    <a href="agenda.php">Agenda</a>
                </li>
                <li class = "<?php if($currentPage =='S_media'){echo 'active';}?>">
                    <a href="s_media.php">Social Media</a>
                </li>
                <li class = "<?php if($currentPage =='Features'){echo 'active';}?>">
                    <a href="features.php">Features</a>
                </li>
                <!--<li class = "<?php if($currentPage ==''){echo 'active';}?>">
                    <a href="#">Event Logistic</a>
                </li>-->
                <li class = "<?php if($currentPage =='Exibition'){echo 'active';}?>">
                    <a href="exibition.php">Exibition</a>
                </li>
                <li class = "<?php if($currentPage =='Contact'){echo 'active';}?>">
                    <a href="contact.php">Contact Us</a>
                </li>
                <li class = "<?php if($currentPage =='presentation'){echo 'active';}?>">
                    <a href="presentation.php">Presentations</a>
                </li>
                <li class = "<?php if($currentPage =='email&tracking'){echo 'active';}?>">
                    <a href="email_track.php">Email & Tracking</a>
                </li>
                <li class = "<?php if($currentPage =='Additional'){echo 'active';}?>">
                    <a href="additional.php">Additional Pages</a>
                </li>
                <li class = "<?php if($currentPage =='menu'){echo 'active';}?>">
                    <a href="create_menu.php">Menu</a>
                </li>
                <li class = "<?php if($currentPage =='booking'){echo 'active';}?>">
                    <a href="booking.php">Bookings</a>
                </li>
                <li class = "<?php if($currentPage =='design'){echo 'active';}?>">
                    <a href="design.php">Design</a>
                </li>
              </ul>
            </div>
      </div>
    </nav>

var hidWidth;
    var scrollBarWidths = 40;

    var widthOfList = function(){
      var itemsWidth = 0;
      $('.list li').each(function(){
        var itemWidth = $(this).outerWidth();
        itemsWidth+=itemWidth;
      });
      return itemsWidth;
    };

    var widthOfHidden = function(){
      return (($('.wrapper').outerWidth())-widthOfList()-getLeftPosi())-scrollBarWidths;
    };

    var getLeftPosi = function(){
      return $('.list').position().left;
    };

    var reAdjust = function(){
      if (($('.wrapper').outerWidth()) < widthOfList()) {
        $('.scroller-right').show();
      }
      else {
        $('.scroller-right').hide();
      }

      if (getLeftPosi()<0) {
        $('.scroller-left').show();
      }
      else {
        $('.item').animate({left:"-="+getLeftPosi()+"px"},'slow');
        $('.scroller-left').hide();
      }
    }

    reAdjust();

    $(window).on('resize',function(e){  
        reAdjust();
    });

    $('.scroller-right').click(function() {

      $('.scroller-left').fadeIn('slow');
      $('.scroller-right').fadeOut('slow');

      $('.list').animate({left:"+="+widthOfHidden()+"px"},'slow',function(){

      });
    });

    $('.scroller-left').click(function() {

        $('.scroller-right').fadeIn('slow');
        $('.scroller-left').fadeOut('slow');

        $('.list').animate({left:"-="+getLeftPosi()+"px"},'slow',function(){

        });
    });    

Я хочу правильно прокрутить меню. когда я добавляю к элементу li больше, чем прокручиваю щелчок кнопки меню, чтобы перейти к последним элементам и пропустить все центральные элементы.

...