PhotoSwipe icon indicating copy to clipboard operation
PhotoSwipe copied to clipboard

Crazy behaviour in zoom mode in Safari ios 15

Open AndrewElans opened this issue 3 years ago • 14 comments

Photoswipe version 4.1.x (not sure which one is on the demo page). After updating to ios 15 strange behavior is noticed in zoom mode in safari. Zoom is not stable and just closes the zoom or moves to another slide after 1) zooming in and 2) trying to move the picture with a finger. Before the update all worked fine. In chrome ios all worked fine.

See the photoswipe demo page demonstrated on video.

Chrome works as it should: https://youtu.be/E-ZIi2lTYfM Safari does not work: https://youtu.be/stcziG4Nl6M

Demo page V5 seems not to have this kind of bug.

AndrewElans avatar Sep 27 '21 19:09 AndrewElans

It's fixed in v5 recently, might be fixed in earlier versions too if I find a way.

iOS15 Safari triggers toolbars on any vertical drag, which triggers resize event. The problem is you can't preventDefault() or do anything to stop this action.

As another solution, you may hide all page content when PhotoSwipe opens, which eliminates scrolling and at the same time toolbar behavior.

dimsemenov avatar Sep 27 '21 21:09 dimsemenov

Will you please advise the best method to hide the page content on safari?

AndrewElans avatar Sep 27 '21 22:09 AndrewElans

Here is the code for v5 https://gist.github.com/dimsemenov/0b8c255c0d87f2989e8ab876073534ea , you may adjust it for earlier versions.

dimsemenov avatar Sep 28 '21 04:09 dimsemenov

In v5 moving horizontal a zoomed image makes moving a little bit the toolbar. While moving vertical makes appear/disappear the toolbar at all. At the moment is there a way to solve both? Thanks

dangelion avatar Oct 06 '21 16:10 dangelion

The best solution I've found so far is in the gist, but it's still far from perfect.

It partly uses a technique from here https://pqina.nl/blog/how-to-prevent-scrolling-the-page-on-ios-safari/

If you'll manage to find something better - please let me know.

dimsemenov avatar Oct 06 '21 19:10 dimsemenov

Thanks @dimsemenov that code is already part of v5.1.5?

dangelion avatar Oct 07 '21 07:10 dangelion

No, it's unlikely that I'll add it in the core, it might break sites. You'll need to add it manually and test it.

I might release it as a plugin though.

dimsemenov avatar Oct 07 '21 09:10 dimsemenov

Works like a charm with photoswipe 4.1.3, slightly modified though. Coupled also with the royalslider.

AndrewElans avatar Oct 11 '21 23:10 AndrewElans

It works on Safari though. Chrome on ios also has a bottom toolbar which disappears on scroll up, and in this case the image in fullscreen is not vertically centered. How to detect safari only on ios?

AndrewElans avatar Oct 12 '21 00:10 AndrewElans

Can we get a fix for v4?

aarxnuk avatar Oct 25 '21 15:10 aarxnuk

Hi @ae202652 Would you please share your fix for v4.1.3? I tried a suggested solution from https://gist.github.com/dimsemenov/0b8c255c0d87f2989e8ab876073534ea but it didn't work for me on iOS 15...

Dmitry2703 avatar Dec 09 '21 12:12 Dmitry2703

@Dmitry2703, please have a look at my website, furulundjordet10c.no, for details of the fix. Photoswipe is combined with the RoyalSlider there. I'm a little busy now to give you a specific answer, if you can't figure out from my code, let me know and I'll give the answer about the fix.

Sorry, but the code is not refactored yet, so may be difficult to read.

I use 4.1.2 by the way, noticed that 4.1.3 has something which is not working, like close on mouse scroll if I'm not mistaken...

AndrewElans avatar Dec 09 '21 20:12 AndrewElans

Hi @ae202652 , Thanks a lot for your quick answer! From my testing on browserstack on iOS15.0 your slider doesn't work on iPhone... When I try to double tap on image it doesn't zoom. Maybe it works on real device or on iOS15.1 but unfortunately I don't have a real device.

Dmitry2703 avatar Dec 10 '21 01:12 Dmitry2703

Hi, @Dmitry2703, on iphone it works as it should on ios 15.1.

Screen Capture of behaviour https://youtu.be/AouKiSe0wp0

AndrewElans avatar Dec 10 '21 08:12 AndrewElans