[英]FancyBox navigation on certain links
Hi there good people of StackOverfow, i need help with visibility of the FancyBox navigation arrows. 嗨,那里的StackOverfow好人,我需要FancyBox导航箭头的可见性帮助。 I need them to be always visible (not only on hover) on image groups, but invisible on videos that open in FancyBox window.
我需要它们在图像组上始终可见 (不仅在悬停时),在FancyBox窗口中打开的视频上不可见 。
the code that I have for images is: 我的图像代码是:
$("a[rel=images]").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none',
'showNavArrows' : 'true',
'titlePosition' : 'over',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-over">Image <strong>'
+ (currentIndex + 1)
+ ' </strong>/ '
+ currentArray.length
+ (title.length ? ' ' + title : '')
+ '</span>';
}
});
and I've added two lines of CSS to make the arrows always visible on the images: 并且我添加了两行CSS,以使箭头始终在图像上可见:
#fancybox-left-ico {left: 20px;}
#fancybox-right-ico {right: 20px;}
The code for opening videos in FancyBox window is: 在FancyBox窗口中打开视频的代码是:
$(".video").click(function() {
$.fancybox({
'padding' : 0,
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'title' : this.title,
'width' : 700,
'height' : 450,
'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
'type' : 'swf',
'swf' : {
'wmode' : 'transparent',
'showNavArrows' : 'false',
'allowfullscreen' : 'true'
}
});
//$('.fancy-ico').hide();
return false;
});
When i click on video link the fancybox window shows both of the navigation arrows, which is understandable since that is what my 2 added lines of CSS are there for. 当我单击视频链接时,fancybox窗口会显示两个导航箭头,这是可以理解的,因为这是我添加的2行CSS所针对的。 When I add a line of code that is something like:
当我添加一行代码时,就像这样:
$('.fancy-ico').hide();
the video window opens up without any arrows which is still good. 视频窗口打开,没有任何箭头,仍然很好。 The problem is when I click on the images again, the arrows don't show up, because I've hidden the arrows with the last jquery line.
问题是当我再次单击图像时,箭头没有显示,因为我用最后一个jquery行隐藏了箭头。
Now my question is how can I make this work? 现在我的问题是我该如何进行这项工作? Where can i insert a piece of code that looks like:
我在哪里可以插入一段看起来像这样的代码:
$('.fancy-ico').show();
Is there some smarter way of doing something like this? 有一些更聪明的方式来做这样的事情吗?
Thank you all for any help 谢谢大家的帮助
You can use to your images code the onStart function: so that, each time the images fancybox loads, it will display the arrows as well. 您可以对图像使用onStart函数进行编码:这样,每次在图像fancybox加载时,它也会显示箭头。
$("a[rel=images]").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none',
'showNavArrows' : 'true',
'titlePosition' : 'over',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
return '<span id="fancybox-title-over">Image <strong>' + (currentIndex + 1) + ' </strong>/ ' + currentArray.length + (title.length ? ' ' + title : '') + '</span>';
}
// onStart: "Will be called right before attempting to load the content"
'onStart' : function() {$('.fancy-ico').show();}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.