Couple more places needed touch_id()

This commit is contained in:
Kovid Goyal 2017-05-29 14:43:38 +05:30
parent 017117e6bd
commit b928034dcb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -13,10 +13,14 @@ PINCH_THRESHOLD = 10 # pixels
gesture_id = 0 gesture_id = 0
def touch_id(touch):
# On Safari using touch.identifier as dict key yields a key of "NaN" for some reason
return touch.identifier + ''
def copy_touch(t): def copy_touch(t):
now = window.performance.now() now = window.performance.now()
return { return {
'identifier':t.identifier, 'identifier':touch_id(t),
'page_x':v'[t.pageX]', 'page_y':v'[t.pageY]', 'viewport_x':v'[t.clientX]', 'viewport_y':v'[t.clientY]', 'page_x':v'[t.pageX]', 'page_y':v'[t.pageY]', 'viewport_x':v'[t.clientX]', 'viewport_y':v'[t.clientY]',
'active':True, 'mtimes':v'[now]', 'ctime':now, 'is_held':False, 'x_velocity': 0, 'y_velocity': 0 'active':True, 'mtimes':v'[now]', 'ctime':now, 'is_held':False, 'x_velocity': 0, 'y_velocity': 0
} }
@ -109,11 +113,6 @@ def tap_on_link(gesture):
return False return False
def touch_id(touch):
# On Safari using touch.identifier as dict key yields a key of "NaN" for some reason
return touch.identifier + ''
class TouchHandler: class TouchHandler:
def __init__(self): def __init__(self):
@ -129,7 +128,7 @@ class TouchHandler:
t = self.ongoing_touches[tid] t = self.ongoing_touches[tid]
if t.active: if t.active:
if now - t.mtimes[-1] > 3000: if now - t.mtimes[-1] > 3000:
expired.push(t.identifier) expired.push(touch_id(t))
for tid in expired: for tid in expired:
v'delete self.ongoing_touches[tid]' v'delete self.ongoing_touches[tid]'
@ -207,7 +206,8 @@ class TouchHandler:
def handle_touchcancel(self, ev): def handle_touchcancel(self, ev):
ev.preventDefault(), ev.stopPropagation() ev.preventDefault(), ev.stopPropagation()
for touch in ev.changedTouches: for touch in ev.changedTouches:
v'delete self.ongoing_touches[touch.identifier]' tid = touch_id(touch) # noqa: unused-local
v'delete self.ongoing_touches[tid]'
self.gesture_id = None self.gesture_id = None
self.handled_tap_hold = False self.handled_tap_hold = False