0

PhotoswipeGalleryで問題が発生しました。私が直面している問題は、サムネイルをクリックすると、ページ全体とそのコントロールが画像とともに読み込まれ、空白のページだけが表示されることです。

これは、標準のブラウザとChromeの両方で、私のモバイルデバイス(android 4.0.4)でのみ発生します。しかし、私のラップトップのFirefoxとChromeはどちらも正常に機能しています。

Chromeリモートデバッガーを接続しましたが、すべて正常に動作しているようです。

Chromeモバイルでは#&ui-state=dialog、Android標準ブラウザ、デスクトップChrome、FirefoxではURLハッシュが変更されず、ハッシュが変更されずに表示されます#pageid

コードをデバッグしようとしましたが、何が悪いのかわかりません。

ギャラリーのマークアップはpagebeforechangeイベントに挿入されます。そして、Photoswipeは次のように初期化されます。

(function(window, $, PhotoSwipe){
    $(document).ready(function(){
        console.log('document ready')

        $('div.gallery-page').live('pageshow', function(e){
            console.log('pageshow');
            var currentPage = $(e.target);
            var options = { enableMouseWheel: false , enableKeyboard: false };                    
            var photoSwipeInstance = $("ul.gallery a", e.target).photoSwipe(options,  currentPage.attr('id'));
            console.log(e.target);

            return true; 
        }).live('pagehide', function(e){

            var currentPage = $(e.target),
                photoSwipeInstance = PhotoSwipe.getInstance(currentPage.attr('id'));

            if (typeof photoSwipeInstance != "undefined" && photoSwipeInstance != null) {
                PhotoSwipe.detatch(photoSwipeInstance);
            }

            return true;
        });
    });

}(window, window.jQuery, window.Code.PhotoSwipe)); 

モバイルデバイスでのみ、ページが空白になる理由について何か考えはありますか?

//現在、pagebeforechangeイベントで回避策を編集しています:

if(window.location.hash.search(/ui-state=dialog/) !== -1 ) {
    console.log('ui-state anomaly');
    e.preventDefault();
}
4

1 に答える 1

0

私は同じ問題を抱えていて、https://github.com/codecomputerlove/PhotoSwipe/issues/375で解決策を見つけました

また、上記の最初のコードですべての「.live」を「.on」に置き換えました。「YourGalleryDiv」を独自のdivに置き換えてください。

$(document).bind('pagebeforechange', function(e) {
if ($('.ps-carousel').length) {
$('body').removeClass('ps-active');
$('#YourGalleryDiv').each(function(){
    var photoSwipe = window.Code.PhotoSwipe;
    var photoSwipeInstance = photoSwipe.getInstance($(this).attr('id'));
    if (typeof photoSwipeInstance != "undefined" && photoSwipeInstance != null) {
        photoSwipe.unsetActivateInstance(photoSwipeInstance);
    }
});
}
});
于 2012-12-02T18:42:01.143 に答える