简体   繁体   中英

Photoswipe (mobile) - image selection (photoswipe open) stops working from time to time

This is a shot in the dark, but I'm having an issue with Photoswipe (v4.1.3) using the multi-gallery implementation . The touch-to-open-gallery on mobile stops working after 2-3 touch-and-close's. What I have to do is to move the gallery away from view and bring it back into view to enable touch-to-open-gallery.

In Chrome's DevTool, the mobile simulator works fine. It's just that when I use Photoswipe on an iPhone, I have this issue.

Again, a shot in the dark... If you would like me to provide code snippets, I'd be happy to do so.

Ok, if anyone sees this in the future, you'll understand that on mobile (true mobile), opening an image in a Photoswipe gallery can be a nightmare IF there is a hash in your base URL.

eg:
https://myurl.com/#about - Nightmare
https://myurl.com/ - OK

I solved this issue by simply setting history in options to false . That's it. Now you can be fancy and only target history manipulation for mobile, because having history: true for desktop IS a nice feature.

// stuff above

var $pswp = $('.pswp')[0],
  options = {
    index: $(this).parent('figure').index(),
    bgOpacity: 0.85,
    showHideOpacity: true,
    history: false,  // set this to false - it's true by default
  };

// stuff below

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM