Javascript 在移动设备上的JQuery移动应用程序中使用Photoswip的空白页
我的Photosweep图库有问题。 我遇到的问题是,我点击缩略图、完整页面及其控件以及图像正在加载,然后只显示一个空白页面 这只发生在我的移动设备(android 4.0.4)上,无论是在标准浏览器中还是在chrome中。但我的笔记本电脑上的firefox和chrome都运行良好 我安装了chrome远程调试器,一切都正常 在android标准浏览器、桌面chrome和firefox中,在chrome mobile上,url哈希将更改为Javascript 在移动设备上的JQuery移动应用程序中使用Photoswip的空白页,javascript,jquery-mobile,jquery-plugins,cross-browser,Javascript,Jquery Mobile,Jquery Plugins,Cross Browser,我的Photosweep图库有问题。 我遇到的问题是,我点击缩略图、完整页面及其控件以及图像正在加载,然后只显示一个空白页面 这只发生在我的移动设备(android 4.0.4)上,无论是在标准浏览器中还是在chrome中。但我的笔记本电脑上的firefox和chrome都运行良好 我安装了chrome远程调试器,一切都正常 在android标准浏览器、桌面chrome和firefox中,在chrome mobile上,url哈希将更改为#&ui state=dialog,哈希不会改变并显示#p
#&ui state=dialog
,哈希不会改变并显示#pageid
我试着调试代码,但我无法找出哪里出了问题
库标记被注入到pagebeforechange
事件中。Photosweep初始化如下:
(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();
}
我也遇到了同样的问题,并在 还将您在上面发布的初始代码中的所有“.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);
}
});
}
});