jackmoore / zoom

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

Help with touchstart touchend #75

Open DrLulz opened 9 years ago

DrLulz commented 9 years ago

Hello.
The first example works as expected, but once touchend has been called further zooming is disabled.
The second example needs two touches two initiate the zoom, but otherwise works as expected.
Any help is most appreciated.

$('img').parent().zoom({callback:
      function(){
        $(this).on('touchend', function(){
            $(this).trigger('zoom.destroy');
        });
      }
    });
$('img').parent().on('touchstart', function(){
        $(this).parent().zoom({callback:
          function(){
            $(this).on('touchend', function(){
                $(this).trigger('zoom.destroy');
            });
          }
        });
    });
cristianoap commented 8 years ago

Try this:

var options = {callback:
      function(){
        $(this).on('touchend', function(){
            $(this).parent().trigger('zoom.destroy').zoom(options);
        });
      }
    };
$('img').parent().zoom(options);