替换PhotoSwipe库中的图像

Tim*_*imm 3 javascript photoswipe

我的页面上有一个PhotoSwipe库,它以编程方式创建,如下所示:

var instance = window.Code.PhotoSwipe.attach(image, options)
Run Code Online (Sandbox Code Playgroud)

现在我想更新图库中的图像,或者将新图库放在同一位置.

为此创建新图库会DOM Element忽略以下错误:

Code.PhotoSwipe.activateInstance:
Unable to active instance as another instance is already active for this target
Run Code Online (Sandbox Code Playgroud)

从Element中分离实例Code.PhotoSwipe.detatch(instance)也没有帮助.

任何想法如何用新图像填充图库,或删除它,所以我可以在同一个地方创建一个新的?

Jua*_*ado 8

我发现避免该错误的唯一方法是unsetActivateInstance之前调用detatch:

window.Code.PhotoSwipe.unsetActivateInstance(instance);

window.Code.PhotoSwipe.detatch(instance); 
Run Code Online (Sandbox Code Playgroud)