【问题标题】:JQuery javascript Galleria IO spliceJQuery javascript Galleria IO拼接
【发布时间】:2013-09-19 14:31:23
【问题描述】:

我有一个使用IO 的画廊,一切运行顺利,但是当我尝试删除画廊上选定的图像时遇到问题。

这是我正在使用的代码

var gallery  = $('#galleriaID').data('galleria');
var index = gallery.getIndex();
gallery.splice(index,1);
gallery.next();

一切运行顺利,但是当我尝试删除图库上的 penultimate 图像时,并没有删除,而我正在观看的控制台中的图库是 blocked

TypeError: data is undefined
version "+version+" to use one or more components.";if(Galleria.version<version...
galler...BC32189 (line 3)
TypeError: self.getData(...) is undefined

我知道只是试图删除图库中的penultimate 图像我做错了什么有一些解决方法吗??

非常感谢...

【问题讨论】:

    标签: javascript jquery fullscreen zk galleria


    【解决方案1】:

    我自己一直在解决同样的问题,并且有一个合理的解决方法,使用 show()setIndex()galleria-1.3.js 一起使用:

    var galleria = $('#galleria').data('galleria');
    var galleriaLength = galleria.getDataLength();
    var currentIndex = galleria.getIndex();
    var nextIndex = (currentIndex == galleriaLength - 1) ? 0 : currentIndex + 1;
    
    // Remove the image from the Galleria film slideshow
    galleria.splice(currentIndex, 1);
    
    if (galleriaLength > 1) {
      // Need to use show() and setIndex() because next() doesn't work on the
      // penultinate image.
      galleria.show(nextIndex);
      galleria.setIndex((nextIndex == 0) ? 0 : nextIndex - 1);
    
      // Set a delay of 50ms because there seems to be a race condition
      // of trying to preload images that haven't been spliced out of
      // the gallery yet (working theory).
      galleria.lazyLoadChunks(10, 50);
    
      // Hack to set the counter because setCounter() isn't working here
      $('.galleria-counter .galleria-current').html(indexToSet + 1);
    } else {
      // Destroy Galleria when there are no more images
      galleria.destroy();
    }
    

    【讨论】:

    • indexToSet?在哪里定义
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-24
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-20
    • 1970-01-01
    相关资源
    最近更新 更多