1

ギャラリーに15枚の画像があり、「Image1of15」のようなものを追加したいとします。以前のバージョンでは、次のようなものを使用できました。

'titlePosition': 'over'
'titleFormat': function(currentArray, currentIndex, currentOpts) { return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>'

どんな助けでもいただければ幸いです。

4

2 に答える 2

3

この方法で行うことができますDEMO

<script type="text/javascript">
$(document).ready(function() {
 $('.fancybox').fancybox({
  prevEffect : 'fade',
  nextEffect : 'fade',
  afterLoad : function() {
   this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
  },
  helpers: {
   title: {
    type: 'inside'
   },
   thumbs: {
    width   : 50,
    height  : 50
   }
  }
 });
});
</script>
于 2012-04-20T13:32:16.843 に答える
0

別の質問から: 「[...] バージョン 2.0.6 では、v2.0.1 で行ったように afterLoad コールバックを使用できません (これがタイトルを非表示にする原因です).... beforeShow を使用します。代わりは。"

それで:

  beforeShow : function() {
   this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
  }

動作します!

于 2012-08-27T14:35:26.810 に答える