javascript - MaterializeCSS轮播设置起始图片无效果
问题描述
我正在尝试在全屏MaterializeCSS
轮播中设置起始位置。我想将它用作全屏模式内的画廊图像查看器。单击图库图像后,modal
打开和图像滑块应从单击的图像开始。在MaterializeCSS
我的文档中找不到任何重要信息。
目前,轮播会滑动到正确的图像。我只想on start
在查看第一张图片后删除幻灯片效果并激活它。
要打开的许多图像中的两个:
<div class="gallery-item-left col s12 m6">
<img class="responsive-img gallery-item" alt="gallery-image-1" data-position="1" src="...path-to-image-1..." />
</div>
<div class="gallery-item-right col s12 m6">
<img class="responsive-img gallery-item" alt="gallery-image-2" data-position="2" src="...path-to-image-2..." />
</div>
...
我的 jQuery 代码
jQuery(document).ready(function($) {
$('body').on('click', '.gallery-item', function() {
var position = $(this).data('position');
$('#img-viewer-modal').modal('open');
$('#img-viewer-carousel').carousel({fullWidth: true, duration: 400});
$('#img-viewer-carousel').carousel('set', [position - 1]);
});
#img-viewer-carousel只是我模式中的轮播ID。
我非常感谢每一个提示。
解决方案
我发现的唯一解决方法是动态更改轮播的内容项。
推荐阅读
- javascript - Joi 如何合并/追加/添加子模式取决于特定的输入
- arduino - Arduino nano、mini DFplayer MP3 断开连接
- python - 在保持相同列的同时取消堆叠 Multiindex Pandas DataFrame
- java - 并行流 Java 8 的 CPU 内核数
- c# - net 2 上的 C# 多线程,firebird 数据库取消并重新启动,如何?
- php - Elasticsearch“你的意思是”功能
- android - ffmpeg 命令创建可共享到 Instagram 等的 mp4 视频
- java - 使用 apache Shiro 会话到期时如何重新登录?
- json - 将命令的输出转换为有效的 json?
- reactjs - Formik 和反应自动完成