我有一個頁面,使用fancybox 2.1.4顯示多個不同的圖像畫廊,根據其各自的rel
屬性。fancybox圖像計數標題顯示
我一直在努力獲取當前圖像標題中顯示的每個圖庫的圖像數量。在複製由JFK通過this Stack Overflow post描述的方法之後,其餘腳本將變爲禁用狀態。
我的代碼如下。誰能幫忙?
<script type="text/javascript">
$(document).ready(function() {
$(".fancybox").fancybox({
helpers : {
title: {
type: 'outside'
}
}, // helpers
afterLoad : function() {
this.title = (this.title ? " + this.title + '<br />' : ") + 'Image ' + (this.index + 1) + ' of ' + this.group.length;
}
});
//start fade transition
(function ($, F) {
F.transitions.resizeIn = function() {
var previous = F.previous,
current = F.current,
startPos = previous.wrap.stop(true).position(),
endPos = $.extend({opacity : 1}, current.pos);
startPos.width = previous.wrap.width();
startPos.height = previous.wrap.height();
previous.wrap.stop(true).trigger('onReset').remove();
delete endPos.position;
current.inner.hide();
current.wrap.css(startPos).animate(endPos, {
duration : current.nextSpeed,
easing : current.nextEasing,
step : F.transitions.step,
complete : function() {
F._afterZoomIn();
current.inner.fadeIn();//this rule controls the fadein of the next image
}
});
};
}(jQuery, jQuery.fancybox));
$(".fancybox")
/*.attr('rel', 'gallery')// am commenting this out so each gallery only loops through itself versus into the next gallery*/
.fancybox({
nextMethod : 'resizeIn',
nextSpeed : 200,//this rule controls the white flash action that happens just after an image is advanced
prevMethod : false,
helpers : {
title : {
type : 'outside'
}
}
}); //end fade transition
});
</script>
jsfiddle.net請 –
這裏是一個小提琴:http://jsfiddle.net/bzelip/HGxHg/ –
你綁定選擇器'.fancybox'到fancybox兩次,所以第二個覆蓋第一個。此外,您應該使用'beforeShow'而不是'afterLoad' for v2.1.x – JFK