如何销毁jqPhotoSwipe

时间:2018-06-29 17:33:21

标签: javascript jquery

我想在jqPhotoSwipe之后销毁uikit filterhttps://github.com/ergec/jQuery-for-PhotoSwipe)画廊,以便更新index

这是destroy的方法:http://photoswipe.com/documentation/api.html

但是我没有设法...

JS

$(document).ready(function() {
    var mosaic = $('.js-filter li');
    mosaic.jqPhotoSwipe({
        forceSingleGallery: true
    });
});
$('[uk-filter]').on('afterFilter', function() {
     // destroy PhotoSwipe here and build another one
});

JSFIDDLE

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我的解决方案:

$(document).ready(function() {
    var pswp = function() {
        var mosaic = $('.js-filter li');
        mosaic.jqPhotoSwipe({
            forceSingleGallery: true,
        });
    };
    pswp();
    $('[uk-filter]').on('afterFilter', function() {
        pswp = null;
        var mosaic = $('.js-filter li:visible');
        mosaic.jqPhotoSwipe({
            forceSingleGallery: true,
        });

    });
});

JSFIDDLE