javascript - Swiper - 2 列拇指幻灯片,活动幻灯片并不总是在视图中
问题描述
当我多次单击主“英雄”滑动滑块(10)时。视图中的拇指不同步,活动拇指不再在视图中。
我正在尝试在引导模式中将两个滑动滑块链接在一起。拇指滑块是一个垂直的两列滑块,并链接到模态内的主要“英雄”滑块。
向下滚动页面并单击“查看 23 张照片”以打开模式。 https://transmission.mecum.tv/2019/06/18/milk-money/
const $id = $(this).attr('id');
modalThumbs = new Swiper('#' + $id + ' .gallery-modal-thumbs .swiper-container', {
direction: 'vertical',
observer: true,
observeParents: true,
spaceBetween: 20,
slidesPerColumn: 2,
slidesPerView: 5,
navigation: {
nextEl: '#' + $id + ' .modal-thumb-next button',
prevEl: '#' + $id + ' .modal-thumb-prev button',
},
});
modalHero = new Swiper('#' + $id + ' .gallery-modal-hero .swiper-container', {
loop: true,
observer: true,
observeParents: true,
simulateTouch: false,
spaceBetween: 0,
speed: 500,
navigation: {
nextEl: '#' + $id + ' .modal-hero-next button',
prevEl: '#' + $id + ' .modal-hero-prev button',
},
pagination: {
el: '#' + $id + ' .swiper-pagination',
type: 'fraction',
},
thumbs: {
swiper: gallerySliders[$id].modalThumbs,
},
});
活动的缩略图幻灯片应始终可见。
解决方案
似乎自动高度计算以及两列布局可能有问题。现在移动到下一张幻灯片,脚本.translate3d()
在 Y 轴上使用一个图像的高度来滚动拇指。如果您通过Parameters
设置为图像的一半高度(将是 52 像素而不是 104 像素)手动设置高度,则当前显示的元素不应移出视图。初始化将与此类似:
var thumbsSwiper = new Swiper('.swiper-container-thumbs', {
slidesPerView: 10,
height: 52
});
推荐阅读
- office-js - Outlook 加载项事件侦听器
- postgresql - uuid 作为散列分区的主键和分区键
- c# - C# Razor - 如何从字符串中删除双引号
- laravel - Laravel 5.6 测试 Notification::assertSentTo() 未找到
- swift - 分裂SpriteKit的无限背景问题
- c# - C# 文本文件到字符串数组以及如何删除特定字符串?
- amazon-web-services - AWS Cloudformation 创建堆栈模板错误
- c++ - 需要使用 :: 和 memcopy
- git - 如何将我的代码推送到 Intellij 的 Github 上的新存储库?
- python - python 纸浆:如何创建 LpMaximize 和 LpMinimize 问题?