codecomputerlove/PhotoSwipe — Issue #226: Android reset issue
Author: Lexance
Created: 2011-12-25 20:57:51+00:00
State: open

Hey there;
i'm tryin to work a litter "deep linking" feature for my own site with address plugin(http://www.asual.com/jquery/address/). I deactivated the haslistening and other native jqm features, and the sit's running perfectly. But there is a little issue in the actual standart browser of the actual android version(2.3.5)

Here is the code:

(function(window, PhotoSwipe){
document.addEventListener('DOMContentLoaded', function(){
var active = false;
var options = {	preventSlideshow: true,
preventHide: false,
enableUIWebViewRepositionTimeout: true,
backButtonHideEnabled:false,
getImageMetaData: function(el){
return {rel: el.getAttribute('rel'), title: el.getAttribute('title')}
},preventDefaultTouchEvents: true };
// init address handler
$.address.init();

// handle address changeing
$.address.change(function(event){
if( event.path.search("\/p\/") == -1 ) { // load normal pages
active = false;
$.mobile.changePage( event.path );
}else{
if(active == false){
$.mobile.loadPage( event.path ).done(function(e, data){
photoSwipeInstance = $("div.gallery-page ul.gallery-site a").photoSwipe(options);

var path = event.path.replace("/p/", "").replace("/", "");

$("div.gallery-page ul.gallery-site a").each(function(index) {
if($(this).attr("rel") == path && active == false){
photoSwipeInstance.show(index);
active = true;
}
});

photoSwipeInstance.addEventHandler("PhotoSwipeOnDisplayImage", function(e){
var currentImage =photoSwipeInstance.getCurrentImage();
$.address.path("/p/"+currentImage.metaData.rel);
});

photoSwipeInstance.addEventHandler("PhotoSwipeOnToolbarTap", function(e){
if(e.toolbarAction == "close"){
var currentImage =photoSwipeInstance.getCurrentImage();
$.address.path('/photography/'+currentImage.metaData.title);
Code.PhotoSwipe.detatch(photoSwipeInstance);
}
});
});
} // already called
} // gallery end
}); // address end
}, false);
}(window, window.Code.PhotoSwipe));

I know, this is not the best solution but i'm new in the world of javascript.
I already tried to alert the PhotoSwipeOnResetPosition event to see when the event fires. In the acutal chrome and iOS Safari and other browser it fires as expected. But not in my andorid browser...

Besides being just a great plugin, keep it up!
lex

PS: sorry for my bad english...