B
B
BIGO232017-12-01 18:46:36
JavaScript
BIGO23, 2017-12-01 18:46:36

Does the slider scroll through one slide?

There is a slider, it does not work correctly, flips through the slide
I can’t understand what’s wrong
here is the code

<div class="carousel-container2">
            <div class="carousel"><a class="control-next" href="#">Prev</a> <a class="control-prev" href="#">Next</a>

                <ul style="width: 2094px; margin-left: -698px;">
                    <li><img alt="" src="/bg/zvn/1.jpg" /></li>
                    <li><img alt="" src="/bg/zvn/2.jpg" /></li>
                    <li><img alt="" src="/bg/zvn/3.jpg" /></li>
                </ul>
            </div>
            <a class="btn zakaz" href="#">Заказать консультацию</a>
    </div>

here is js
$(function() {
  
  var slideCount = $('.carousel ul li').length;
  var slideWidth = $('.carousel ul li').width();
  var slideHeight = $('.carousel ul li').height();
  var sliderUlWidth = slideCount * slideWidth;
  
  $('.carousel ul').css({ width: sliderUlWidth, marginLeft: - slideWidth });
  
    $('.carousel ul li:last-child').prependTo('.carousel ul');

    function moveLeft() {
        $('.carousel ul').animate({
            left: + slideWidth
        }, 500, function () {
            $('.carousel ul li:last-child').prependTo('.carousel ul');
            $('.carousel ul').css('left', '');
        });
    };

    function moveRight() {
        $('.carousel ul').animate({
            left: - slideWidth
        }, 500, function () {
            $('.carousel ul li:first-child').appendTo('.carousel ul');
            $('.carousel ul').css('left', '');
        });
    };

    $('.carousel a.control-prev').click(function () {
        moveLeft();
    return false;
    });

    $('.carousel a.control-next').click(function () {
        moveRight();
    return false;
    });
  
  $('.tab-menu .item').mouseover(function(e) {
    $('.tab-menu .item').removeClass('active');
        $(this).addClass('active');
    
    var index = $('.tab-menu .item').index(this);
    
    $('.tab-content .poly').removeClass('active').eq(index).addClass('active');
    });
  
});

link where the slider is located
http://sem-nebo.ru/natyazhnye-potolki/v-vannoy/
5a2178a89f34a170358505.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
ned4ded, 2017-12-02
@BIGO23

Good evening. The app.js file containing the executing code for this slider is included in two places. I believe that removing one of the references to it eliminates the problem, because eventlistner is hung on the button twice.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question