【问题标题】:Swap Images in Galleria on click单击即可在 Galleria 中交换图像
【发布时间】:2018-05-28 20:58:07
【问题描述】:

我有一个图片库来展示我正在开发的游戏的屏幕截图,我想对这些图片做一些前后对比。我希望所有后图像正常显示为画廊默认值。对于之前的图像,虽然我希望它们在单击时显示在相应的后图像上,而不是所有的图像都只是单击。我希望这是一个切换开关,以便他们可以单击以在新旧版本之间来回切换以进行比较。

【问题讨论】:

    标签: galleria


    【解决方案1】:

    Nm,想通了。我在 Galleria.run 函数中使用了它。

                        extend: function(options) {
    
                        Galleria.log(this) // the gallery instance
                        Galleria.log(options) // the gallery options
    
                        // listen to when an image is shown
                        this.bind('image', function(e) {
    
                            Galleria.log(e) // the event object may contain custom objects, in this case the main image
                            Galleria.log(e.imageTarget) // the current image
    
                            // lets make galleria open a lightbox when clicking the main image:
                            $(e.imageTarget).click(this.proxy(function() {
                                //this.openLightbox();
                                if (e.imageTarget.src.includes("Old")) {
                                    e.imageTarget.src = e.imageTarget.src.replace("-Old.png", ".png");
                                } else {
                                    e.imageTarget.src = e.imageTarget.src.replace(".png", "-Old.png");
    
                                }
                                //e.imageTarget.src = "../images/Games/TheVoid/MenuScreen-Old.png";
                            }));
                        });
                    }
    

    您当然可以将其调整为不同的东西,但我就是这样做的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多