diff --git a/src/ngTouchmove.js b/src/ngTouchmove.js index 946424a..5b5901e 100644 --- a/src/ngTouchmove.js +++ b/src/ngTouchmove.js @@ -4,9 +4,11 @@ angular.module("ngTouchmove", []).directive("ngTouchmove", function () { return { controller: function ($scope, $element, $attrs) { $element.bind('touchstart', onTouchStart); + var startEvent; function onTouchStart(event) { event.preventDefault(); + startEvent = event; $element.bind('touchmove', onTouchMove); $element.bind('touchend', onTouchEnd); }; @@ -19,6 +21,13 @@ angular.module("ngTouchmove", []).directive("ngTouchmove", function () { function onTouchEnd(event) { event.preventDefault(); + if (startEvent + && typeof event.pageX !== 'undefined' + && event.pageX === startEvent.pageX + && event.pageY === startEvent.pageY + ) { + angular.element($element).triggerHandler('click'); + } $element.unbind('touchmove', onTouchMove); $element.unbind('touchend', onTouchEnd); };