这是一个Flickity旋转木马,其中包含在PhotoSwipe打开的图像。
Flickity幻灯片中有a
标签“工作”,但PhotoSwipe模式在window.location
更改之前闪烁(默认HTML单击)。
我在运行openPhotoSwipe()
之前需要进行某种测试并尝试了以下方法,但它(当然)仅适用于第二次点击:
$gallery.dataset = [];
$gallery.dataset.linkClicked = false;
$('.project-archive-link').on('click', function() {
$gallery.dataset.linkClicked = true;
});
$gallery.on('staticClick.flickity', function(event, pointer, cellElement, cellIndex) {
if (!cellElement) {
return;
}
// Photoswipe functions
var openPhotoSwipe = function() {
...
if ($gallery.dataset.linkClicked === false ) {
openPhotoSwipe();
}
这是一个基本框架的CodePen。
我打赌我的做法是错的。
由fazxswpoi,flickity的开发人员根据working solution开发了this recommendation(未经广泛测试),David DeSandro的进一步输入用this Flickity issue获得的细胞指数取代cellIndex
。
Flickity事件侦听器绑定到jQuery
中的img
标记。然后目标的$gallery
的index
被用作它的parent
数组中的Photoswipe图像。
options