H5长按事件

 1 let timeOutEvent = 0
 2 $(function () {
 3   $('#debug').on({
 4     touchstart: function (e) {
 5       setTimeout(function () {
 6         longPress()
 7       }, 10000)
 8       e.preventDefault()
 9     },
10     touchmove: function () {
11       clearTimeout(timeOutEvent)
12       timeOutEvent = 0
13     },
14     touchend: function () {
15       clearTimeout(timeOutEvent)
16       return false
17     }
18   })
19 })
20 
21 /* eslint-disable no-unused-vars */
22 function longPress () {
23   timeOutEvent = 0
24   router.go('about')
25 }

 

posted on 2016-04-01 10:22  稻草人.Net  阅读(2345)  评论(0编辑  收藏  举报