galleria - 单击即可在 Galleria 中交换图像
问题描述
我有一个图片库来展示我正在开发的游戏的屏幕截图,我想对这些图片进行前后处理。我希望所有后图像正常显示为画廊默认设置。对于之前的图像,虽然我希望它们在单击时显示在相应的后图像上,而不是所有的图像都只是单击。我希望这是一个切换,以便他们可以单击以在新旧版本之间来回切换以进行比较。
解决方案
纳米,想通了。我在 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";
}));
});
}
您当然可以将其调整为不同的东西,但这就是我的做法。
推荐阅读
- android - Gradle 构建在启用与多模块的数据绑定时失败
- asp.net - 过滤下拉列表选项服务器端 asp.net
- python - 拆分多个(嵌套)python 子正则表达式定义
- python - Visual Studio Code 快速修复 & python
- javascript - 通过另一个数据属性作为标识符获取元素的数据属性
- python-3.x - matplotlib 动画在循环执行的文件更新中不起作用
- python - 将自定义生成器添加到 spaCy 的类
- android - 授予位置权限时,Android O 设备中的“位置方法”不会更改
- ag-grid - rowNode.setDataValue 方法的性能
- asp.net - 检查对 SOAP/REST Web 服务的访问而不调用它