Fix pinch to change font size not working on Safari

This commit is contained in:
Kovid Goyal 2017-05-29 13:19:38 +05:30
parent 6c670b22a4
commit 03b3d93bfc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -109,6 +109,11 @@ 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):
@ -162,7 +167,7 @@ class TouchHandler:
ev.preventDefault(), ev.stopPropagation() ev.preventDefault(), ev.stopPropagation()
self.prune_expired_touches() self.prune_expired_touches()
for touch in ev.changedTouches: for touch in ev.changedTouches:
self.ongoing_touches[touch.identifier] = copy_touch(touch) self.ongoing_touches[touch_id(touch)] = copy_touch(touch)
if self.gesture_id is None: if self.gesture_id is None:
nonlocal gesture_id nonlocal gesture_id
gesture_id += 1 gesture_id += 1
@ -180,7 +185,7 @@ class TouchHandler:
def handle_touchmove(self, ev): def handle_touchmove(self, ev):
ev.preventDefault(), ev.stopPropagation() ev.preventDefault(), ev.stopPropagation()
for touch in ev.changedTouches: for touch in ev.changedTouches:
t = self.ongoing_touches[touch.identifier] t = self.ongoing_touches[touch_id(touch)]
if t: if t:
self.update_touch(t, touch) self.update_touch(t, touch)
self.dispatch_gesture() self.dispatch_gesture()
@ -188,7 +193,7 @@ class TouchHandler:
def handle_touchend(self, ev): def handle_touchend(self, ev):
ev.preventDefault(), ev.stopPropagation() ev.preventDefault(), ev.stopPropagation()
for touch in ev.changedTouches: for touch in ev.changedTouches:
t = self.ongoing_touches[touch.identifier] t = self.ongoing_touches[touch_id(touch)]
if t: if t:
t.active = False t.active = False
self.update_touch(t, touch) self.update_touch(t, touch)