在我的手机应用程序来处理单个HTML元素上多点触摸事件,我已经在那里我展示的内容主要观点,在HTML:如何采用了棱角分明的指令
<div class="imageView" na-swipe="next()" na-tap="showControls()"> content here </div>
为了使用处理swipe
和touch
事件jQuery的(或Hammer.js),我创建了这两个指令:
angular.module("naModule").directive 'naTap', ->
(scope, element, attrs) ->
tapping = false
element.bind 'touchstart', -> tapping = true
element.bind 'touchmove', -> tapping = false
element.bind 'touchend', -> scope.$apply(attrs['naTap']) if tapping
angular.module("naModule").directive 'naSwipe', ->
(scope, element, attrs) ->
tapping = false
swiping = false
element.bind 'touchstart', -> tapping = true
element.bind 'touchmove', -> swiping = true
element.bind 'touchend', -> scope.$apply(attrs['naSwipe']) if (swiping and tapping)
的naSwipe
似乎运作良好,这是next()
无论何时进行刷卡叫...然而,当我点击next()
和showControls()
都在触发... 我该如何干净地分开触摸并在这一个div上滑动?谢谢。