Three synchronized slides in the Owl Carousel

I am currently in search of a solution to synchronize owl carousel slides.

Already managed to sync two slides successfully, but now looking for a way to have one slide represent a category and the second slide display variable content related to different categories.

My initial approach involved duplicating the code for two slides and modifying all classes and attributes, but this has resulted in confusion across the various slides.

Seeking advice on an alternative solution to implement this concept effectively.

Javascript

var sync1 = $(".service-line");
var sync2 =$(".servicetext");

$(".service-line").owlCarousel({
    navigation: false,
    pagination: true,
    slideSpeed: 1000,
    paginationSpeed: 500,
    paginationNumbers: true,
    singleItem: true,
    autoPlay: false,
    autoHeight:false,
    animateIn: 'slideIn',
    animateOut: 'slideOut',
    afterAction : syncPosition,
    responsiveRefreshRate : 200,
    afterMove: afterAction
});

function afterAction(){
   $( ".owl-item.active" ).find( "animation-cap" ).addClass( "animated", "bounce" );
}

$(".servicetext").owlCarousel({
     items: 1,
     pagination: false,
     slideSpeed: 800,
     paginationSpeed: 700,
     animateIn: 'slideIn',
     animateOut: 'slideOut',
     autoHeight: true,
     responsiveRefreshRate : 100,
     mouseDrag: false,
     afterInit : function(el){
         el.find(".owl-item").eq(0).addClass("synced");
     }
});

function syncPosition(el){
    var current = this.currentItem;
    $(".servicetext")
      .find(".owl-item")
      .removeClass("synced")
      .eq(current)
      .addClass("synced");
    if($(".servicetext").data("owlCarousel") !== undefined){
      center(current);
    }
  }

  $(".servicetext").on("click", ".owl-item", function(e){
    e.preventDefault();
    var number = $(this).data("owlItem");
    sync1.trigger("owl.goTo",number);
  });

  function center(number){
    var sync2visible = sync2.data("owlCarousel").owl.visibleItems;
    var num = number;
    var found = false;
    for(var i in sync2visible){
      if(num === sync2visible[i]){
        var found = true;
      }
    }

    if(found===false){
      if(num>sync2visible[sync2visible.length-1]){
        sync2.trigger("owl.goTo", num - sync2visible.length+1);
      }else{
        if(num - 1 === -1){
          num = 0;
        }
        sync2.trigger("owl.goTo", num);
      }
    } else if(num === sync2visible[sync2visible.length-1]){
      sync2.trigger("owl.goTo", sync2visible[1]);
    } else if(num === sync2visible[0]){
      sync2.trigger("owl.goTo", num-1);
    }

  }



<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<div class="konfig-slide-top"> <!--TOP Slider #1 -->

  <!--TOP SLIDER slide1-->
  <div class="slider-wrap">
    <div class="slide-content">
      <div class="container">
        <div class="row">
          <div class="col-xs-12 animation-cap">
            <h2>Category 1</h2>
          </div>
        </div>


      </div>
      <!--img src="img/service/01.png" alt="01"-->
    </div>

  </div><!--slide1 ends-->

  <!--TOP SLIDER slide2-->
  <div class="slider-wrap">
    <div class="slide-content">
      <div class="container">
        <div class="row">
          <div class="col-xs-12 animation-cap">
            <h2>Category 1</h2>
          </div>
        </div>


      </div>
      <!--img src="img/service/01.png" alt="01"-->
    </div>

  </div><!--slide2 ends-->


</div>
<!-- Top Slider ends -->

<!-- Bottom Slider Starts -->
<div class="konfig-slide-bottom">

  <!-- ======  BOTTOM SLIDER Slide 1 ====== -->
  <div class="row">
    <div class="row lower-input-main">
      <!-- ======  INNER SLIDER Slide starts ====== -->
      <div class="konfig-slide-bottom-inner">
        <div class="row">
          <!--inner slider slide 1 -->

          <div class="col-md-12">
            <h1 style="color:white;">Slide 1 inner slide</h1>
          </div>
        </div>

        <div class="row">
          <!--slide 2 inner slide -->

          <div class="col-md-12">
            <h1 style="color:white;">Slide 2 inner slide</h1>
          </div>
        </div>

      </div>



    </div>
  </div>
</div>

Answer №1

Apologies for my previous errors. Fortunately, I revisited the task this morning and successfully completed it. All I need now is to share my code to mark this question as answered.

This is my jQuery code:

var synctop = $(".konfig-slide-top");
    var syncbottom =$(".konfig-slide-bottom");


    $(".konfig-slide-top").owlCarousel({
        navigation: true,
        pagination: false,
        slideSpeed: 1000,
        paginationSpeed: 500,
        paginationNumbers: false,
        singleItem: true,
        autoPlay: false,
        autoHeight:false,
        animateIn: 'slideIn',
        animateOut: 'slideOut',
        afterAction : syncPositionnew,
        responsiveRefreshRate : 200,
        afterMove: afterActionnew
    });

    $(".konfig-slide-bottom").owlCarousel({
        items: 1,
        pagination: ...

<p>The HTML structure of konfig-slide-inner nested in konfig-slide-bottom is as follows:</p>

<pre><code><div class="konfig-slide-top">
-slide 1
-slide 2
- etc.
</div>

<div class="konfig-slide-bottom">
  <div class="konfig-slide-inner">
    -slide 1 
       -text 1
       -text 2
       -text 3
    -slide 2
       -text 1
       -text 2
       -text 3
    - etc.
  </div>
</div>

I currently have a synced slider with multiple slides, where the issue arises when konfig-slide-inner transitions from slide1 to slide2 causing text1 in slide2 to not display before jumping directly to text2. This cascades, resulting in subsequent slides missing text content. I am unable to pinpoint the cause of this problem. Any assistance would be greatly appreciated.

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

Centering text both vertically and horizontally over an image using CSS

I've been attempting to center the div banner_title both vertically and horizontally within another div in this way... .box { text-align: center; } .banner_title { font-size: 32px; position: absolute; top: 50%; width: 100%; } .banner_titl ...

Positioning pictures in front of a backdrop

I'm facing an issue with a section that slides into view with a blue background. I want to add a picture in the upper left corner, but it's barely visible and the blue background disappears. Here's a snippet of the HTML code: <header id ...

Error in AJAX Codeigniter - No file selected for upload - Steps to successfully pass the file using AJAX

Currently, I am attempting to upload images using an AJAX call with Codeigniter: This is my View: <?php echo form_open_multipart('upload/do_upload'); ?> <input type="file" name="userfile" id="userfile" size="20" ...

Start fresh with the count for every individual table

In my HTML document, I have multiple tables with columns that have classes "valuation" and "valuation_all". If one cell in the "valuation" column contains the text "FAIL", then the corresponding cell in the "valuation_all" column should display "FAIL"; oth ...

How to position footer at the bottom of pages in asp.net MVC without displaying a scrollbar for shorter pages

Thanks to a useful tip I found on Stack Overflow, I was able to position the footer at the bottom of all my pages in ASP MVC. I created a custom stylesheet called "mystyles" where I defined classes for .wrapper, .footer, and .push. In the _layout file, wit ...

Merging two JSON objects in the absence of one

function fetchData(url) { return fetch(url).then(function(response) { return response.json(); }).then(function(jsonData) { return jsonData; }); } try { fetchData(`https://api.hypixel.net/skyblock/auctions?key=${apikey}`).the ...

Obtaining and Assigning Filter Values in Material Table

Is there a way to programmatically obtain and adjust filter values with material-table? I am looking to enable users to save filter settings as reports and access them whenever necessary. ...

What is the best way to maintain the selected row during pagination in Yii?

Currently, I am facing an issue with pagination while viewing table rows. My requirement is to select different rows from various pages and then submit the form. The problem occurs when I select rows from one page, navigate to another page to make more se ...

Unlock the Potential of Spring REST-JWT-JavaScript for Seamless Transitions

In my Java Spring REST back-end, I am implementing a security feature using Json Web Tokens instead of sessions. For the front-end, I plan to use JavaScript and jQuery for sending requests to the back-end, along with HTML. After a successful login, I stor ...

Capable of generating a string-keyed map that results in an "Unexpected number error" when the key is referenced

Take a look at the following code snippet: var arr = [{"id":"123", "name":"Jyotirmoy"}]; var mapObj = {}; for(var i=0; i < arr.length; i++){mapObj[arr[i].id] = arr[i];} After creating the map, attempting to access it using the key 'mapObj.123&ap ...

Combine linear and radial background effects in CSS styling

I am trying to achieve a background design that includes both linear and radial gradients. The linear gradient should display a transition from blue to white, while the radial gradient should overlay a polka dot pattern on top of it. I have been following ...

Combine all alt values of html tags within a selenium Webelement into a single string

What is the best way to extract all alt values from img tags and convert them into a sentence while preserving the order of surrounding text: (Note: the number of img tags between the texts may vary) <img alt="one"> Bobby gave: <img alt ...

Adding to object in an external JSON file using javascript

I am working with an external file called file.json which contains the following values: { "number": "value" } My goal is to run a function that will append new data to the existing file instead of overwriting it. For instance, after running the func ...

Ways to showcase angular scope data within a placeholder while avoiding the use of angular expressions

Initially, I utilized angular expressions {{value}} to present values within elements. However, upon noticing that unrevealed expressions continue to display on the front end during loading delays, I switched to using ng-bind. <div> <h1>Hell ...

Find the specific size of an HTML element

How can you retrieve an element's dimensions while avoiding CSS properties that take up unnecessary space? For example: <!DOCTYPE html> <html> <head> <style> #foo { height: 48px; margin: 64px; ...

The type 'void | Observable<User>' does not include the property 'subscribe'. Error code: ts(2339)

authenticate() { this.auth.authenticate(this.username, this.password).subscribe((_: any) => { this.router.navigateByUrl('dashboard', {replaceUrl: true}); }); } I'm puzzled by this error message, I've tried a few solu ...

Sort an array in descending order based on the key using JavaScript in Google Chrome

Having an issue with sorting an array in descending order by the key. It works perfectly in Firefox, but Chrome is displaying it in the original order. [["0", 0], ["1", 0.9], ["2", 597.5344192965547], ["3", 991.0326954186761], ["4", 1257.2580315846578], [ ...

jQuery enables the creation of fresh form fields

Currently, I am working on a form that initially consists of 2 text input fields. The typical use case involves the user entering a number in one field and their name in the other. Following this, the page updates itself without reloading. However, there a ...

executing dual success handlers during Ajax requests

I am currently in the process of developing a web application that involves numerous ajax requests spread out across various templates. My approach includes using ajaxSetup on the main template, which serves as the base for all other templates. Within thi ...

What is the method for showing a JavaScript variable in a popup window?

I am having an issue with a search form that is supposed to display a list of persons based on filters. Once the search results are shown, I want a link (id=names_list) that, when clicked, will open a dialog box containing the names of the persons. I have ...