@mpxjs/api-proxy
Advanced tools
Comparing version 2.9.6 to 2.9.9
{ | ||
"name": "@mpxjs/api-proxy", | ||
"version": "2.9.6", | ||
"version": "2.9.9", | ||
"description": "convert miniprogram API at each end", | ||
@@ -42,3 +42,3 @@ "module": "src/index.js", | ||
}, | ||
"gitHead": "9034343edacc95da66b6e8ddb5c2f64a4be97231" | ||
"gitHead": "7ec6526f024c00f9c6b935c631bfdc61be27b69b" | ||
} |
@@ -0,1 +1,3 @@ | ||
import { isBrowser } from './utils' | ||
function webHandleSuccess (result, success, complete) { | ||
@@ -36,19 +38,27 @@ typeof success === 'function' && success(result) | ||
function bindTap (dom, handler) { | ||
let startTime = 0; let x = 0; let y = 0 | ||
const touchStart = (e) => { | ||
startTime = Date.now() | ||
x = e.touches[0].pageX | ||
y = e.touches[0].pageY | ||
} | ||
const touchEnd = (e) => { | ||
if (Date.now() - startTime < 300 && Math.abs(e.changedTouches[0].pageX - x) < 10 && Math.abs(e.changedTouches[0].pageY - y) < 10) { | ||
handler(e) | ||
const isTouchDevice = isBrowser && document && ('ontouchstart' in document.documentElement) | ||
if (isTouchDevice) { | ||
let startTime = 0; let x = 0; let y = 0 | ||
const touchStart = (e) => { | ||
startTime = Date.now() | ||
x = e.touches[0].pageX | ||
y = e.touches[0].pageY | ||
} | ||
const touchEnd = (e) => { | ||
if (Date.now() - startTime < 300 && Math.abs(e.changedTouches[0].pageX - x) < 10 && Math.abs(e.changedTouches[0].pageY - y) < 10) { | ||
handler(e) | ||
} | ||
} | ||
dom.addEventListener('touchstart', touchStart) | ||
dom.addEventListener('touchend', touchEnd) | ||
return () => { | ||
dom.removeEventListener('touchstart', touchStart) | ||
dom.removeEventListener('touchend', touchEnd) | ||
} | ||
} else { | ||
dom.addEventListener('click', handler) | ||
return () => { | ||
dom.removeEventListener('click', handler) | ||
} | ||
} | ||
dom.addEventListener('touchstart', touchStart) | ||
dom.addEventListener('touchend', touchEnd) | ||
return () => { | ||
dom.removeEventListener('touchstart', touchStart) | ||
dom.removeEventListener('touchend', touchEnd) | ||
} | ||
} | ||
@@ -55,0 +65,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131313
3462