-
-
Save ilmsg/5611256 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.stoppingPropagation = (callback) -> (e) -> | |
e.stopPropagation() | |
callback(e) | |
angular.module('myApp',[]).directive 'ngTap', -> | |
(scope, element, attrs) -> | |
tapping = false | |
element.bind 'touchstart', stoppingPropagation (e) -> tapping = true | |
element.bind 'touchmove', stoppingPropagation (e) -> tapping = false | |
element.bind 'touchend', stoppingPropagation (e) -> scope.$apply(attrs['ngTap']) if tapping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.stoppingPropagation = function(callback) { | |
return function(e) { | |
e.stopPropagation(); | |
return callback(e); | |
}; | |
}; | |
angular.module('myApp', []).directive('ngTap', function() { | |
return function(scope, element, attrs) { | |
var tapping; | |
tapping = false; | |
element.bind('touchstart', stoppingPropagation(function(e) { | |
return tapping = true; | |
})); | |
element.bind('touchmove', stoppingPropagation(function(e) { | |
return tapping = false; | |
})); | |
return element.bind('touchend', stoppingPropagation(function(e) { | |
if (tapping) { | |
return scope.$apply(attrs['ngTap']); | |
} | |
})); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment