javascript - nanogallery2:单击缩略图时是否可以转到链接而不是打开灯箱
问题描述
我正在使用 [nanogallery2][1]。我将一些项目动态添加到我的画廊(通过使用此示例:https ://codepen.io/Kris-B/pen/wJKowg )。我知道通过设置该选项thumbnailOpenImage: false
,我们可以在单击缩略图时禁用显示灯箱。是否可以为图库中的项目设置链接,以便在用户触摸缩略图时将其发送到该链接?
解决方案
您可以使用属性定义自定义 URL destinationURL
。
从上面提到的 Codepen,这里有一个例子:
...
// create the new item
var ID = ngy2data.items.length + 1;
var albumID = '0';
var newItem = NGY2Item.New(instance, 'new berlin ' + ID, '', ID, albumID, 'image', '' );
// define thumbnail -> image displayed in the gallery
newItem.thumbSet( baseURL + 'berlin2t.jpg', 135, 204); // w,h
// define URL of the media to display in lightbox
newItem.setMediaURL( baseURL + 'berlin2.jpg', 'img');
// DEFINE YOUR SPECIFIC URL
newItem.destinationURL = "[CUSTOM_URL]";
...
无需禁用该thumbnailOpenImage
选项。
替代解决方案:
使用fnThumbnailOpen
回调。
这是一个示例,显示如何用 Fancybox 替换内部灯箱:https ://codepen.io/Kris-B/pen/zZNMJj
推荐阅读
- node.js - 在托管程序中将我的域重定向到我的 vps 服务器不起作用
- rust - 在 Rust 的 Cursive 库中更新 TextView 的正确方法
- android - Android/Kotlin 中的操作顺序
- javascript - javascript按目录读取多个文件
- c# - Unity 3d 碰撞检测
- android - 使用 Mapbox Android 中的循环从 geojson 添加许多符号图标?
- sockets - 游戏客户端如何从服务器接收 UDP 数据?
- ios - 如何从 Gmail 应用程序嵌入式 Safari 浏览器在 iOS 上调试“400 错误请求”
- python - 在 Python 中使用范围函数
- python - 为接受两个参数的 C 模板类创建 Python 绑定