替换PhotoSwipe库中的图像 [英] Replace images in PhotoSwipe gallery

查看:104
本文介绍了替换PhotoSwipe库中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a PhotoSwipe gallery on my page which is created programatically like this:

var instance = window.Code.PhotoSwipe.attach(image, options)

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

Now I want to update the images in the gallery, or put a new gallery in the same spot.

创建一个相同 DOM元素的新图库忽略以下错误:

Creating a new gallery for the same DOM Element omits the following error:

Code.PhotoSwipe.activateInstance:
Unable to active instance as another instance is already active for this target

使用 Code.PhotoSwipe.detatch(实例)从元素中分离实例也没有帮助。

Detaching the instance from the Element using Code.PhotoSwipe.detatch(instance) didn't help either.

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

Any ideas how to fill the gallery with new images, or remove it, so I can create a new one in the same place?

推荐答案

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

The only way I found to avoid that error was calling unsetActivateInstance before detatch:

window.Code.PhotoSwipe.unsetActivateInstance(instance);

window.Code.PhotoSwipe.detatch(instance); 

这篇关于替换PhotoSwipe库中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆