fat / zoom.js

Medium's Image Zoom for jQuery
https://fat.github.io/zoom.js
MIT License
4.04k stars 331 forks source link

It does not work on mobile browser #56

Open chenweiyj opened 9 years ago

chenweiyj commented 9 years ago

I use responsive design on my website. The zoom works in desktop browser. However, when I test it on my iphone with safari browser, it does not work.

My code for the image is shown as follows.

<img ng-src="{{m.image + '-commsg'}}" alt="A photo to complement the communication" style="width:80vw;max-width:300px;background-color:#EAEAEA" data-action="zoom">
kingdido999 commented 9 years ago

I think the problem is your image width. Notice that it makes no sense to zoom an image if its width is already greater than or equal to a calculated width (screen width - offset):

if (target.width >= ($(window).width() - Zoom.OFFSET)) return // line 34

It's very likely that width:80vw exceeds the threshold. So I tested it on chrome developer tool with iPhone 5 and an image with width:80vw:

> $(window).width()
> 320
> $('.img').width()
> 256

Obviously, 256 >= 320 - 80 (offset), the image will not zoom.

fabiocaccamo commented 8 years ago

I just opened an issue about mobile zooming: https://github.com/fat/zoom.js/issues/75

oninross commented 6 years ago

plugin update: its in line 41 now. Just comment it out or toggle the operators to suit your liking

if (target.width >= ($(window).width() - Zoom.OFFSET)) return