The Bootstrap carousel is experiencing unresponsiveness

While I successfully built a carousel for my clients that works perfectly on non-bootstrap platforms, I encountered some issues when trying to make it responsive on Bootstrap. It seems that there is a JavaScript issue that is preventing it from working properly.

Here is the code snippet:

var $clientcarousel = $('#clients-list');
var clients = $clientcarousel.children().length;
var clientwidth = (clients * 140); 
$clientcarousel.css('width', clientwidth);

var rotating = true;
var clientspeed = 1800;
var seeclients = setInterval(rotateClients, clientspeed);

// Mouse hover events
$(document).on({
  mouseenter: function() {
    rotating = false; // turn off rotation when hovering
  },
  mouseleave: function() {
    rotating = true;
  }
}, '#clients');

function rotateClients() {
  if (rotating != false) {
    var $first = $('#clients-list li:first');
    $first.animate({
      'margin-left': '-140px'
    }, 600, function() {
      $first.remove().css({
        'margin-left': '0px'
      });
      $('#clients-list li:last').after($first);
    });
  }
}
})
#clients {
  display: block;
}

#clients .clients-wrap {
  display: block;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
}

/* CSS styling for client list items */
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container-fluid">
  <div class="row">
    <div id="clients">
      <div class="clients-wrap">
        <ul id="clients-list" class="clearfix navbar">
          <li class="nav-item"><img class="nav-link img-fluid" src="_images/client01-cartoon-network.png" alt="Cartoon Network"></li>
          <li class="nav-item"><img class="nav-link img-fluid" src="_images/client02-rough-draft-studios.png" alt="Rough Draft Studios"></li>
          <li class="nav-item"><img class="nav-link img-fluid" src="_images/client03-spongebob-movie2.png" alt="SpongeBob Movie #2"></li>
          <li class="nav-item"><img class="nav-link img-fluid" src="_images/client04-apple-inc.png" alt="Apple Computers"></li>
          <li class="nav-item"><img class="nav-link img-fluid" src="_images/client05-google-talk.png" alt="Google chat talk"></li>
          <li class="nav-item"><img class="nav-link img-fluid" src="_images/client06-g4tv.png" alt="G4TV channel"></li>
          <li class="nav-item"><img class="nav-link img-fluid" src="_images/client07-wonka-candy.png" alt="Wonka Chocolates and Candy"></li>
        </ul>
      </div>
    </div>
  </div>

</div>

Answer №1

latest version of the code:

I have updated the jQuery version to

https://code.jquery.com/jquery-3.1.0.js


    <div class="container-fluid">
    <div class="row">
    <div class="col-12">


      <div id="clients">
        <div class="clients-wrap">
          <ul id="clients-list" class="clearfix navbar">
            <li class="nav-item"><img class="nav-link img-fluid" src="http://i.imgur.com/sqOrTvo.png" alt="Cartoon Network"></li>
            <li class="nav-item"><img class="nav-link img-fluid" src="http://imgur.com/Eu0IboI.png" alt="Rough Draft Studios"></li>
            <li class="nav-item"><img class="nav-link img-fluid" src="http://imgur.com/n0RJ0p3.png" alt="SpongeBob Movie #2"></li>
            <li class="nav-item"><img class="nav-link img-fluid" src="http://imgur.com/VdV6cWz.png" alt="Apple Computers"></li>
            <li class="nav-item"><img class="nav-link img-fluid" src="http://imgur.com/VdV6cWz.png" alt="Google chat talk"></li>
            <li class="nav-item"><img class="nav-link img-fluid" src="http://imgur.com/udZvHOB.png" alt="G4TV channel"></li>
            <li class="nav-item"><img class="nav-link img-fluid" src="http://imgur.com/EehPfDN.png" alt="Wonka Chocolates and Candy"></li>
          </ul>
        </div><!-- @end .clients-wrap -->
      </div><!-- @end #clients -->
    </div;
    </div>
    </div>



<script>
    var $clientcarousel = $('#clients-list');
    var clients = $clientcarousel.children().length;
    var clientwidth = (clients * 140); // width of each client item is set to 140px
    $clientcarousel.css('width', clientwidth);

    var rotating = true;
    var clientspeed = 1800;
    var seeclients = setInterval(rotateClients, clientspeed);

    $(document).on({
        mouseenter: function() {
            rotating = false; // stop rotation on hover
        },
        mouseleave: function() {
            rotating = true;
        }
    }, '#clients');

    function rotateClients() {
        if (rotating != false) {
            var $first = $('#clients-list li:first');
            $first.animate({
                'margin-left': '-140px'
            }, 600, function() {
                $first.remove().css({
                    'margin-left': '0px'
               });
                $('#clients-list li:last').after($first);
            });
        }
    }
</script>

new fiddle link

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to break out of an endless loop in Node.js and Express.Js

I have developed an Express app that is designed to paginate through an external API call. I have thoroughly examined the code but for some reason, the loop condition to break the function isn't being triggered. Any assistance on this matter would be ...

Executing an AJAX POST request from one domain (localhost:9393) to another domain (localhost:9696) using Spring Rest

I am encountering an issue with a form on one app running on localhost:9393. The JavaScript function used to post data is: function registerClient() { var postData = $("#client-reg").serializeArray(); var formURL = "http://localhost:9393/mPaws/client/re ...

JavaScript: Different ways to utilize the reduce method

Creating an array for search purposes based on a string like BBC Sport, the desired output array will be: [ 'BBC', 'BB', 'B', 'Sport', 'Spor', 'Spo', 'Sp', 'S' ] An implement ...

Is there a way for me to collaborate on a footer control with a different website?

Is it possible to seamlessly incorporate a footer from one website into another? Ideally, I want the footer HTML (and styles) to be dynamically inserted into different web pages. The common workaround is using an iframe, but this causes navigation issues ...

Frozen Blanket: Modifying Particle Velocity

I need assistance adjusting the particle speed in this snowfall animation script. I'm having trouble locating the specific values that control the "Falling Speed." The current speed of the falling particles is too fast, and here is most of the code sn ...

What is the difference between achieving a mirror effect and a steel effect using Three.js?

When using three.js, I find myself a little confused about the concepts of metalness and roughness. Can someone explain the differences between metalness and roughness when applied to materials like mirrors and metals/steel? And furthermore, how can these ...

Is there a way to emphasize the syntax of a displayed <script> tag?

Here is the code snippet I am working with: <!DOCTYPE html> <meta charset="utf-8"> <link rel="stylesheet" href="http://yandex.st/highlightjs/7.3/styles/default.min.css"> <script src="http://yandex.st/highlightjs/7.3/highlight.min.js"& ...

When dealing with lengthy product names, Python Selenium may encounter difficulty retrieving the product's name

I need to extract information about all products (such as name, image, price, and link) from . However, I encountered a problem where the product card cannot display the full name of the product if it is too long, resulting in the name and price being retu ...

AngularJS directive that allows for either a click action to be passed or a ui-router state change to

I have a button (an a tag) that is displayed in multiple locations on my website. It is labeled "View Demo", and sometimes it directs to a demo page using an ui-sref: <a class="btn btn-primary" ui-sref="hamburger-push" target="_blank"> View Demo ...

Error: Unable to access the property 'fontSize' as it is undefined

<!DOCTYPE HTML> <html> <head> <title>Interactive Web Page</title> <link id="mycss" rel="stylesheet" href="mycss.css"> <script> function resizeText(size) { va ...

Looking for assistance navigating through a website's links using Selenium?

Trying to extract links from this webpage, specifically the ones listed in the footer. An example of what I'm dealing with: https://i.sstatic.net/PPvb0.png The goal is to scrape all links related to securities displayed in a table and then navigate ...

Trouble encountered when trying to populate a dropdown column with dynamic data using ajax

In an attempt to populate and append a column, such as Id, with dynamic data using jQuery and AJAX. The data is supposed to be fetched via a rest webservice but seems to be not populating correctly. Below is the code snippet: This pasted code may not wo ...

Display a DIV element sliding in from the left immediately upon website loading

Help needed in creating a jQuery script to smoothly slide a DIV element from <left: -200px> to <left: 0px> right after the page has finished loading. Previous attempts have not been successful, such as: $(window).load(function () { $(" ...

Sliding Navigation Panel

Currently, I am attempting to implement a sidebar push navigation that mimics the one showcased here. My HTML structure includes content within a center element div. The code snippet is as follows: <div id="mySidenav" class="sidenav"> <a href="j ...

When using Owl Carousel in Chrome, the carousel unexpectedly stops after switching tabs

Hi there, I'm currently testing out the auto play feature in owl carousel. One issue I've encountered is that when I switch to another tab in Chrome and then return to my webpage with the carousel, it stops functioning unless I manually drag the ...

What is the best way to eliminate the "0"s from the center of items within an array?

I have developed a table sorter that handles columns containing both letters and numbers, such as "thing 027". To facilitate sorting, I prepended zeros to the numbers. However, I am now looking for a cleaner way to remove these zeros from the numbers using ...

Adding objects to an existing array in Vue.js can be a seamless and

Struggling to populate my existing array with elements from a JSON response using a button click. The issue lies in properly adding these elements to the array. I have an empty array named results where I store the data from the response. export default ...

Next.js strips out query parameters

I've encountered an issue with my Next.js app. I have a page called my-page.jsx. Everything works fine when I navigate to /my-page?x=1&y=2 - the page is rendered correctly and the query parameters are read. However, the problem arises when the par ...

Steps for retrieving the value of a web element and storing it in a string variable in C#

Is it feasible to obtain the input value of an element and store it in a string variable within my C# windows form application? I have located the element like this: IWebElement SearchCounter = Browser.FindElement(By.Id("counter")); Here is the HTML code ...

core.js:12853 Error encountered when trying to use 'ngIf' on a 'div' element that is not recognized as a valid property

I am currently utilizing Angular 9. and I am faced with a scenario where I need to load dynamic components Within one of my components, I encountered the following warning core.js:12853 Can't bind to 'ngIf' since it isn't a known pro ...