Thumbnail Centering Issue in Swiper Plugin by iDangero.us

Currently, I am utilizing the Swiper plugin created by iDangero.us. Within my layout design, there are 6 slider images accompanied by 6 thumbnails.

Surprisingly, when I attempt to center align the thumbnails, it appears to cause issues with the plugin. This is done by adjusting the centeredSlides variable to false.

If you want to take a look at the issue, here's a link to the JSFiddle: https://jsfiddle.net/fa4218de/5/

I would greatly appreciate any assistance in resolving this issue or if there are any alternative solutions available.

For further information on Swipper, please refer to the official API documentation: Swipper API Docs

Answer №1

If you're looking for a solution, here's what I came up with: I created a custom solution by linking the thumbnails to the single swiper and rotating them based on the child number of the thumbnails. Check out the code below:

JS CODE

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

    var galleryTop = new Swiper('.gallery-top', {
        paginationClickable: true,
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
        spaceBetween: 30,

    });

    // Make first child of div active
    $(".portfolios-thumb-wrapper .container .row div:first-child").addClass("active");

    // When click on any of the thumbnails with classname 'slide_no' it 
    // gets the child number of the div and then I just use that number
    // to rotate to that specific slide number by 'slideTo' callback
    $('.slide_no').each(function (i) {
        $(this).click(function (e) {
            e.preventDefault();
            var thumb = i;
            galleryTop.slideTo(thumb, 1000, false);
            $('.slide_no').removeClass('active');
            $(this).addClass('active');

        });
    });
});

PHP WITH HTML (WORDPRESS)

<div class="portfolios-wrapper">
<?php   if ($postslist->have_posts()) : ?>
        <div class="swiper-container gallery-top">
            <div class="swiper-wrapper gallery_top_slides">

        <?php while ($postslist->have_posts()) : $postslist->the_post(); ?>

                <?php 
                $post_id            = $post->ID;
                $permalink          = get_post_permalink($post_id);
                $backgroundImage    = get_post_meta($post_id, 'portfolio_background_image', true);

                ?>

                <div class="swiper-slide top_slide_<?php echo $top_counter; ?>" style="background-image: url('<?php echo $backgroundImage; ?>');">

                    <div class="portfolio-details" style="background-color: transparent">
                        <div class="container" style="background-color: transparent">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="portfolio-thumb">
                                        <?php echo the_post_thumbnail('large'); ?>
                                        <?php echo the_title('<h2>', '</h2>', true); ?>
                                    </div>
                                </div>

                                <div class="col-md-6">

                                    <div class="portfolio-excerpt">
                                        <?php echo the_title('<h2>', '</h2>', true); ?>
                                        <p><?php echo get_the_date('M Y'); ?></p>
                                        <span class="excerpt"><?php echo the_excerpt(); ?></span>
                                    </div>
                                </div>

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

        <php $top_counter++; endwhile; ?gt;
            </div>
            <div class="container custom_adjust">
                <div class="swiper-button-next custom-btn-next">Next</div>
                <div class="swiper-button-prev custom-btn-prev">Previous</div>
            </div>
        </div>
<?php endif; ?>
</div> 

<div class="portfolios-thumb-wrapper">
<?php if ($postslist->have_posts()) : ?>
        <div class="container">
                <div class="row">

            <?php while ($postslist->have_posts()) : $postslist->the_post(); ?>
                
                    <?php if (has_post_thumbnail($post->ID)) : ?>
                        <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); ?>
                    <?php endif; ?>

                    <div class="col-md-2 slide_no">
                        <div class="thumb_slide" style="background-image: url('<?php echo $image[0]; ?>')">
                        </div>
                        <div class="portfolio-title"><?php echo the_title('<h2>', '</h2>', true); ?> </div>
                    </div>  

            <?php $thumb_counter++; endwhile; ?>
                </div>
        </div>

<?php endif; ?>
</div>

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

Acquiring information to display in a div using innerHTML

I aim to create a div that displays different animal sounds, like: Dog says Bark Bark I've attempted various methods but I'm unable to get each pair in the array to show up in a div: const animal = [ {creature: "Dog", sound: "B ...

Maximizing the efficiency of rendering components in Ember JS

I have a situation where I need to render thousands of components inside a wrapper component, but currently only around 300 components are being rendered due to performance issues. How can I achieve this without any rendering delays or performance proble ...

The PageMethods function is successful when using a single parameter, but encounters an error when attempting to use two parameters, resulting in the

PageMethods worked perfectly when sending a single parameter to a code-behind aspx page. However, I encountered the error "Unknown web method" when attempting to provide two parameters (or an Object other than a String). The functional code in my aspx pag ...

Creating a diagonal rectangle with a flat bottom: A step-by-step guide

Hey there, I've encountered a little issue. I managed to create a diagonal shape on my webpage similar to the one shown in this image: https://i.sstatic.net/tMgpd.png Now, what I'm aiming for is something like this: https://i.sstatic.net/xToz7.p ...

Using Django filters alongside pagination results in the same page being displayed even after clicking the next URL

Whenever I search for something (like "tom"), the first page displays the results correctly. However, when I click on the next page URL, it still shows the same results without any changes. The URL, however, changes from to filters.py: class VideoFilter( ...

The radio buttons fail to function properly or update when clicked

Seems like I am facing a strange issue....it seems simple (and trivial for some) but it just won't work. I have a basic div with some radio buttons that are not changing state when clicked... <div id="payments_tab" class="tab-pane fade" data- ...

I am looking to insert a jQuery value or variable into the plugin options

How can I insert a jQuery value or variable into plugin options? This is my current script: $(document).ready(function() { // var bannerheight = 580; if ($(window).width() < 2100) { var bannerheight = 410; var opts = JSON.parse( ...

What steps can be taken to resolve image display issues in a Heroku application?

For the past two days, I've been struggling with a particular issue. I have a Heroku app with a small icon named "icon.png" located in the "assets" folder within the main directory. Here's the directory structure: assets icon.png index.html i ...

Missing out on the opportunity to operate on a GET request

After running the code displayed in the attached screenshot, I observed the following behavior: the FOR loop is executed first, followed by two 'LET' statements (let path_get... and let get = https.get...). Issue: when the second LET statement i ...

Exploring jQuery: Implementing a SlideDown Effect on Loading Questions

Greetings, this is my debut post on stackoverflow. I have been an avid reader and learner here. I am currently using a jQuery function to load posts in WordPress themes using the .load function. However, I am facing a challenge that I cannot resolve on m ...

Using res.sendfile in a Node Express server and sending additional data along with the file

Can a Node.JS application redirect to an HTML file using the res.sendFile method from express and include JSON data in the process? ...

Modify the Ng-Pattern with Jquery

Is there a way for someone to assist me in updating the Ng-Pattern with Jquery? I have looked at the questions below, but they haven't been helpful (Most of them focus on updating to dynamic values using Angular JS). Question 1 Question 2 Question ...

Implementing Real-Time Search Feature Using AJAX

Exploring the world of search functions for the first time, I decided to implement an AJAX function to call a PHP file on key up. However, I encountered some strange behavior as the content in the display area was changing, but not to the expected content. ...

In JavaScript, loop through an array of arrays and combine them using the concat

If I have an array like [["a", "b"], ["c", "d"]], is there a way to iterate, reduce, map, or join this array in order to get the desired output of ["ac", "ad", "bc", "bd"]? What if the array is structured as [["a", "b"], ["c", "d"], ["e", "f"]]; how can we ...

Upgrade to the latest Gulp version and transition away from using the gulp.start function

Currently in the process of updating all my gulp v3 projects to v4, but running into an issue with the gulp start function. Upon executing gulp start in gulp v4, I encounter an error. This was the code snippet I used in v3: gulp.parallel within gulp.seri ...

What is the appropriate command for "building" a fresh NPM project?

I'm currently working on a JS website with Three.js. I kicked off my project like this: $ npm init $ npm install three Can anyone guide me on where to place my code utilizing Three.js, and which npm command should I use to "compile" my script for dep ...

Upload files via Ajax request is required

I am in the process of trying to upload a binary file to a server while avoiding a full page refresh when the server responds. I must admit, I am not well-versed in this area and I understand if my approach needs some adjustments. This is how I have appro ...

Load media upon the click of an image

I'm currently in the process of designing a team page for our website. Each team member's photo is displayed in a grid layout, with two boxes positioned below containing various content. Box 1: This box consists of basic text information. Box 2: ...

Customizing the primary element (<html>) in VueJs Nuxt with unique styles

I have a Vue component that shows a full-size image when a user clicks on an image in a carousel. While the image is open, I want to prevent the user from scrolling the page. Right now, I am directly styling the documentElement with overflow:hidden; or ove ...

Tips for altering the color of spans that share a common top position without affecting the surrounding sibling elements above or below

Is there a way to change the color of spans with the same top position, excluding sibling elements above or below, in a paragraph made up of spans? I've been working on how to change the color of the line of span tags that contain another span with t ...