Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
スマートフォンなどでJavaScriptのクリックイベントが遅れるのを解消する(AngularJS) nd-click="hoge($event)"としても、hogeの中で$eventを取得できません。
angular.module('AngularStudy', []).directive 'ndClick', => ($scope, $element, $attrs) =>
isTap = isTapped = false
$element.bind 'click', => $scope.$apply $attrs['ndClick'] unless isTapped
$element.bind 'touchstart', => isTap = true
$element.bind 'touchmove', => isTap = false
$element.bind 'touchend', => if isTap
isTapped = true
$scope.$apply $attrs['ndClick'], $element
<button nd-click="hoge()">ボタン</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.