0

I'm using ngTouch to remove the delay on mobile devices, but on mobile devices clicking an image does nothing. On my app, clicking an image calls a directive to enlarge the images, so there is no ng-click. Here is the directive:

app.directive('imageZoom', ['ngDialog', function(ngDialog) {
    return {
        restrict: 'A',
        scope: {
            image: '='
        },
        link: function(scope, element, attr) {
            attr.$observe('ngSrc',function(img) {
                element.bind('click', function(e) {
                    e.stopPropagation();
                    if (something) {
                        doSomething();
                    } else {
                        ngDialog.open({
                           some template here
                        });
                    }
                });
            });
        }
    };
}]);

This was working fine until I introduced ngTouch so I believe there is an issue with the element.bind('click' aspect of it where it is not registering the click. It does work perfectly fine on a browser though so the directive does work.

germainelol
  • 3,231
  • 15
  • 46
  • 82

1 Answers1

0

Listen for element.bind('touchstart click', function(){ ... } instead of only click element.bind('click', function(){ ... }.

jad-panda
  • 2,509
  • 16
  • 22
  • I added this, and it works, but if I try to scroll down the page starting from the picture, it will also register that as a click and zoom into the picture. It should only register the click as a click on the image, not as a swipe that starts from the image too. Do you have any ideas? – germainelol Jun 01 '15 at 05:31