Javascript Galleria:跳跳虎在加载或单击时显示哪个图像
我正在使用Galleria插件显示现有标记中无法更改的图像列表 点击一张图片,我正在加载一个灯箱,在灯箱里我有一个图片画廊 我需要的是索引在初始旧标记中单击的图像,然后在galleria中触发相同的索引图像,或者让它最初作为活动图像加载 触发或设置初始幻灯片加载是我遇到问题的地方?任何建议都很好 标记类似于以下内容:Javascript Galleria:跳跳虎在加载或单击时显示哪个图像,javascript,jquery,image-gallery,galleria,Javascript,Jquery,Image Gallery,Galleria,我正在使用Galleria插件显示现有标记中无法更改的图像列表 点击一张图片,我正在加载一个灯箱,在灯箱里我有一个图片画廊 我需要的是索引在初始旧标记中单击的图像,然后在galleria中触发相同的索引图像,或者让它最初作为活动图像加载 触发或设置初始幻灯片加载是我遇到问题的地方?任何建议都很好 标记类似于以下内容: <div class="productSlides"> <img alt="Conti Melamine Desk with Sharknose Edge.jpg
<div class="productSlides">
<img alt="Conti Melamine Desk with Sharknose Edge.jpg" src="/Images/test1.jpg" />
<img alt="Conti-Melamine-Desk-with-Sharknose-Edge-FV.jpg" src="/Images/test2.jpg" />
<img alt="Conti-Glass-Desk-FV.jpg" src="/Images/test3.jpg" />
</div>
<div id="galleria"></div>
<script type="text/javascript">
$( document ).ready(function() {
//Need to have two sets of images. The inital markup that can be clicked, and the same images added to a Galleria tag to render the gallery.
$('.productSlides').clone().appendTo($('#galleria'));
});
Galleria.loadTheme('/UserUploadedJS/galleria.classic.js');
Galleria.run('#galleria', {
});
$( document ).ready(function() {
$('.productSlides img').on('click', function(){
var url = "#galleria"; // sets the link url as the target div of the lightbox
$(this).colorbox({
inline:true, // so it knows that it's looking for an internal href
href:url, // tells it which content to show
width:"70%",
onOpen:function(){ //triggers a callback when the lightbox opens
$(url).show(); //when the lightbox opens, show the content div
},
onCleanup:function(){
$(url).hide(); //hides the content div when the lightbox closes
}
});
var index = $(this).parent().find("img").index(this); //indexes the image cliked
Galleria.ready(function() { //Attempt to show the same indexed image in the galleria
var gallery = this;
gallery.show(index);
});
});
});
</script>
$(文档).ready(函数(){
//需要有两组图像。可以单击的初始标记,以及添加到Galleria标记以呈现画廊的相同图像。
$('.productSlides').clone().appendTo($('.#galleria'));
});
Galleria.loadTheme('/UserUploadedJS/Galleria.classic.js');
Galleria.run(“#Galleria”{
});
$(文档).ready(函数(){
$('.productSlides img')。在('click',function(){
var url=“#galleria”;//将链接url设置为lightbox的目标div
$(此).colorbox({
内联:true,//因此它知道它正在查找内部href
href:url,//告诉它要显示哪些内容
宽度:“70%”,
onOpen:function(){//在lightbox打开时触发回调
$(url).show();//打开lightbox时,显示content div
},
onCleanup:function(){
$(url).hide();//在lightbox关闭时隐藏content div
}
});
var index=$(this.parent().find(“img”).index(this);//为剪辑的图像编制索引
ready(函数(){//尝试在Galleria中显示相同的索引图像
var gallery=这个;
画廊展览(索引);
});
});
});
首先,在galleria的ready活动中获取选定的galleria图像索引,如
Galleria.loadTheme('/UserUploadedJS/galleria.classic.js');
Galleria.run('#galleria',
{
show: selectedIndex
});
var selectedIndex=0;
Galleria.ready(function() { //Attempt to show the same indexed image in the galleria
var gallery = this;
selectedIndex=index;
//gallery.show(index);
});
我已经对代码进行了测试,它在我的末尾工作得很好,添加已经在使用的脚本以获取索引。我编辑了脚本以获得我想要的。也许它对你也有用 我知道现在回答这个问题已经太迟了,但它可以帮助其他人 在我的例子中,galleria.io数据源被更新以根据需要添加更多图像。 然后我打这个电话: Galleria.get(0).load(数据更新,未定义,{show:YOUR_POSITION})强>
load : function( source, selector, config ) {
//...
// use the dataConfig set by option
config = config || o.dataConfig;
// Edited: 20150516 - Added by tuliocacalazans
// Override show position
// Added in line 3840, script version: galleria-1.4.2.js
if (typeof config.show === 'number') {
o.show = config.show; // o = this._options
}
//...
}