This commit is contained in:
Adam Bradley
2015-07-16 14:04:15 -05:00
parent a5e5789323
commit f240083535
23 changed files with 729 additions and 36 deletions

View File

@@ -3,6 +3,10 @@ const DEFAULT_EXPIRE = 330;
let cbEle, fallbackTimerId;
let isShowing = false;
function disableInput(ev) {
ev.preventDefault();
ev.stopPropagation();
}
function show(expire) {
clearTimeout(fallbackTimerId);
@@ -18,6 +22,7 @@ function show(expire) {
cbEle.className = 'click-block ' + CSS_CLICK_BLOCK;
document.body.appendChild(cbEle);
}
cbEle.addEventListener('touchmove', disableInput);
}
}
@@ -26,6 +31,7 @@ function hide() {
if (isShowing) {
cbEle.classList.remove(CSS_CLICK_BLOCK);
isShowing = false;
cbEle.removeEventListener('touchmove', disableInput);
}
}

View File

@@ -158,3 +158,27 @@ export function windowLoad(callback) {
return promise;
}
export function pointerCoord(ev) {
// get coordinates for either a mouse click
// or a touch depending on the given event
let c = { x: 0, y: 0 };
if (ev) {
const touches = ev.touches && ev.touches.length ? ev.touches : [ev];
const e = (ev.changedTouches && ev.changedTouches[0]) || touches[0];
if (e) {
c.x = e.clientX || e.pageX || 0;
c.y = e.clientY || e.pageY || 0;
}
}
return c;
}
export function hasPointerMoved(tolerance, startCoord, endCoord) {
return Math.abs(startCoord.x - endCoord.x) > tolerance ||
Math.abs(startCoord.y - endCoord.y) > tolerance;
}
export function hasFocus(ele) {
return !!(ele && (document.activeElement === ele.nativeElement || document.activeElement === ele));
}

View File

@@ -103,8 +103,8 @@ var tapEventListeners = {
Platform.ready().then(config => {
if (config.setting('tapPolyfill')) {
console.log('Tap.register, tapPolyfill')
Tap.register(document);
// console.log('Tap.register, tapPolyfill')
// Tap.register(document);
}
});