question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

centeredSlides on thumbs

See original GitHub issue

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • Swiper Version: 6.3.2

  • Platform/Target and Browser Versions: macOS

What you did

I’m using Swiper with react. I have main swiper and thumbs for it. I’m trying to center active thumb.

This is the code for main swiper:

<Swiper
    grabCursor
    navigation={{
        nextEl: '.next-btn',
        prevEl: '.prev-btn'
    }}
    onSlideChange={this.handleSlideChange}
    onSwiper={swiper => this.swiper = swiper}
    initialSlide={post.initialSlide}
    threshold={6}
    thumbs={{swiper: this.state.thumbsSwiper}}
>
...
</Swiper>

… And this for thumbs:

<Swiper
    onSwiper={thumbsSwiper => this.setState({thumbsSwiper})}
    watchSlidesVisibility
    watchSlidesProgress
    slidesPerView={12}
    spaceBetween={12}
    threshold={6}
    centeredSlides
    centeredSlidesBounds
>

Expected Behavior

Expected active thumb to be centered if slides > slidesPerView.

Actual Behavior

Now active slide only tries to be visible on screen. It never moves if is visible on screen. It moves only when grabbing.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
JackCAcommented, Aug 30, 2021

I believe I’m trying to solve the same problem and have recreated it here.

What I’d like to happen, is that the active thumbnail is always centered (unless it is the first 2 or last 2 in my above example).

Is there a way to natively achieve this?

0reactions
laurabennettcommented, Oct 25, 2022

Is this plugin still maintained? This is still an issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Swiper: Thumbs centered slides - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >
How to center Swiper Slider thumbs with custom width?
No way to answer (To know why) - your thumbs do not align center. Look at the example I made (Works fine //...
Read more >
centeredSlides with thumbnail problem | Swiper - Muut
Ok.. so what can I do if I want the thumbs float left? Vladimir Kharlampidi. 04 Mar 2015. Don't use control, or use...
Read more >
Thumbs Gallery With Two-way Control - React-id-swiper
Thumbs Gallery With Two-way Control. import React, { useState, useEffect, useRef } from ... centeredSlides: true,. slidesPerView: 'auto',. touchRatio: 0.2,.
Read more >
Swiper API
... swiper/less/scrollbar - styles required for Scrollbar module; swiper/less/thumbs - styles required for Thumbs module ... Required centeredSlides: true .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found