我遇到了Photoswipe圖庫的問題。 我遇到的問題是,我點擊縮略圖,整個頁面及其控件,加載圖像,然後只顯示一個空白頁面。在移動設備上的JQuery Mobile應用程序中使用Photoswipe的空白頁
這隻發生在我的移動設備上(android 4.0.4),無論是在標準的瀏覽器和鉻。但我的筆記本電腦上的Firefox和Chrome都正常工作。
我附加了chrome遠程調試器,並且一切似乎工作正常。
在Chrome移動版本中,android標準瀏覽器,桌面瀏覽器和firefox中的url-hash更改爲#&ui-state=dialog
,哈希值不會更改並顯示#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();
}