我有一个使用IO
的Galleria,一切运行顺利,但是当我尝试删除图库中的所选图像时,我遇到了问题。
这是我正在使用的代码
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
图像我做错了有一些解决方法吗?
非常感谢...
答案 0 :(得分:2)
我自己一直在处理同一问题,并使用与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();
}