problem with centering image in popup

problem with centering image in popup

hi guys,
I am using jqm to developer a simple web app for my company, which includes a sequence of images that will popup when users click on them.

My problem is when I click on the images, jqm suppose will help to center the popup image, but mine is not. 
The position is not proper, especially  when I keep clicking other images one by one. And the scale of the first-popped image will not be scaled to fit the screen....
However, if I change the browser size, the image will be centered again...

I just use the sample code from the jqm document.
  1. $( ".photopopup" ).on({
  2. popupbeforeposition: function() {
  3. var maxHeight = $( window ).height() - 60 + "px";
  4. var maxWidth = $( window ).width() * 0.8 + "px";
  5. $( ".photopopup" ).css( "max-height", maxHeight );
  6. $( ".photopopup" ).css( "max-width", maxWidth );
  7. console.log( maxWidth+ ' ' + maxHeight);
  8. }
  9. popupatferclose: function() {
  10.   $(".photopopup img").attr("src",'');
  11.   // $( ".photopopup" ).popup('close') ;
  12. }
  13. });

here is my testing link

Thanks for helping~