1

我有一个画廊,使用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画廊中的图像我做错了什么有一些解决方法?

多谢...

4

1 回答 1

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();
}
于 2013-10-24T14:33:26.503 回答