【问题标题】:Don't show thumbnails if Galleria has only one image如果 Galleria 只有一张图片,则不显示缩略图
【发布时间】:2014-10-03 11:35:41
【问题描述】:

我正在使用 Galleria (http://galleria.io/) 并动态生成图片到画廊,偶尔会出现画廊只包含一张图片的情况,此时我希望画廊在没有缩略图的情况下出现容器,我该怎么做?

非常感谢任何帮助!

我当前的初始化脚本是:

Galleria.loadTheme('assets/js/galleria.classic.min.js');

// Initialize Galleria
Galleria.run('#galleria', {
  show: selectedIndex,
  showInfo: false,
  swipe: true,
  imageCrop: false,
  responsive:true,
  showCounter:true,
  thumbnails:true,
  lightbox: true,
  trueFullscreen:true,
  extend: function() {
    this.bind(Galleria.IMAGE, function() {
      $('#description').html(this.$('info-title').html());
      $('.galleria-lightbox-title').html(this.$('info-title').html());
    })
  }
}); 

【问题讨论】:

    标签: javascript jquery galleria


    【解决方案1】:

    试试缩略图:$("#galleria img").size()>1

    【讨论】:

      【解决方案2】:
       $('#galleria img:only-child').hide();
      

      当父元素只有单数时,您需要选择它的子元素 - 一个缩略图 - jQuery 选择器 only-child 允许这样做 - 然后将语句链接到 hide() 以隐藏它。

      【讨论】:

      • 虽然这段代码 sn-p 可以解决问题,但including an explanation 确实有助于提高帖子的质量。请记住,您正在为将来的读者回答问题,而这些人可能不知道您的代码建议的原因。也请尽量不要用解释性 cmets 挤满你的代码,因为这会降低代码和解释的可读性!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多