jackmoore / zoom

jQuery plugin for zooming images on mouseover.
http://www.jacklmoore.com/zoom/
MIT License
1.54k stars 459 forks source link

Problems on iOS #3

Open d2s opened 12 years ago

d2s commented 12 years ago

Tested how this little thing works and while it works nicely on desktop browsers, had some interesting problems on Mobile WebKit (iOS 5.0.1) running on iPad. When tapping image content area, it zooms to the one specific point but it isn't possible to move the zoomed image around. It could be possible with ontouchmove –type of event triggers.

Understandably there aren't support for touch based browsers at the moment. If someone is interested of trying to add that, there is more details on Safari Web Content Guide about differences in the way how WebKit handles touch based events.

Luoti commented 11 years ago

I did a quick fix for this when using the plugin on the "on click" event. I did not submit a Pull Request, because I feel this is way too raw to be included in the main code.

My fix was to change the beginning oh the move function (starting from a line 62) to look like this:

function move(e) {
    if (e.type == 'touchmove')
    {
        left = (e.originalEvent.touches[0].pageX - offset.left);
        top = (e.originalEvent.touches[0].pageY- offset.top);
    }
    else
    {
        left = (e.pageX - offset.left);
        top = (e.pageY - offset.top);
    }

    if (left > outerWidth) {
        left = outerWidth;
    } else if (left < 0) {
        left = 0;
    }

and starting from line 151

start(e);

$(document)[mousemove](move);
$(document).on('touchmove', move);

$(document).one('click',
    function () {
        stop();
        clicked = false;
        $(document).unbind(mousemove, move);
        $(document).off('touchmove', move);
    }
);
gonzzza007 commented 7 years ago

This code (move function) is now updated. However the problems on IOS (chrome) still exist. I can zoom the image one of 10 times. Another 9 times the zoom is reset in fraction of the second.