-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(thumb): active class gets removed #5826
fix(thumb): active class gets removed #5826
Conversation
when using library / framework components the classes get updated on events or lifeycle hooks that are conflicting with the synchronous execution expectation of the thumbs module
ccd11e6
to
167fdd6
Compare
@nolimits4web I am using Swiper JS Slider, thumbs events for the slider, and I am displaying 30 Images in the navigation click. For the slide of images 1 and 3, it was 1st slide and the second slide and showed the third slide. what I need is if I click the third image the element has to be show 3rd and no other image has to slide. Thanks. |
i have similar issue swiper-slide-thumb-active is not applied in production build but work in local env interface Props { // product gallery breakpoints const swiperParams: SwiperOptions = { const ThumbnailCarousel: React.FC = ({ return ( <div className={cn( 'relative mb-2.5 w-full overflow-hidden rounded-md border border-border-base md:mb-3 xl:ltr:ml-5 xl:rtl:mr-5', thumbnailClassName )} > {!!thumbsSwiper ? ( <Swiper id="productGallery" thumbs={{ swiper: thumbsSwiper }} modules={[Navigation, Thumbs]} navigation={{ prevEl: prevRef.current!, // Assert non-null nextEl: nextRef.current!, // Assert non-null }} {...swiperParams} > {gallery?.map((item) => ( <SwiperSlide key={ product-gallery-${item.id} }className="flex items-center justify-center" > <Image src={item?.original ?? productGalleryPlaceholder} alt={ Product gallery ${item.id} }// width={650} // height={590} width={540} height={440} className="rounded-lg object-contain" /> ))} ) : ( <Swiper id="productGallery" modules={[Navigation, Thumbs]} navigation={{ prevEl: prevRef.current!, // Assert non-null nextEl: nextRef.current!, // Assert non-null }} {...swiperParams} > {gallery?.map((item) => ( <SwiperSlide key={ product-gallery-${item.id} }className="flex items-center justify-center" > <Image src={item?.original ?? productGalleryPlaceholder} alt={ Product gallery ${item.id} }width={540} height={440} className="rounded-lg object-contain" /> ))} )} {dir === 'rtl' ? : } {dir === 'rtl' ? : } {/* End of product main slider */}
) export default ThumbnailCarousel import 'swiper/css'; |
The thumbs active class get's applied and removed right after when the thumbs slider slides the next group of thumbs into view. This only happens when using the library or framework components as those are emitting the
_slideClass
update event as part of sliding to the next thumbs group. At this time they do not yet contain the class information of the new active thumb, then the active thumbs class gets toggled via direct dom manipulation and afterwards the emitted events from before that where being queued are executed and remove the active class again. This PR prevents this behavior by toggling the thumb active classes before emitting the events.Relates issues: #5501, #4748