Skip to content

Commit 09fcffb

Browse files
committed
add workaround to filter redundant hammer touch event following mouse event on desktop chrome touchscreen; see hammerjs/hammer.js#1084 and related
1 parent aa9dd89 commit 09fcffb

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/focus.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@ import {mixinEventEmitter} from '@theatersoft/bus'
44
const stack = [] // stack of sinks
55
let sink = {}
66

7+
const filterTouchMouse = _touch => f => e => {
8+
if (e.type === 'tap') {
9+
if (_touch && e.gesture.pointerType === 'mouse') {
10+
_touch = false
11+
return
12+
}
13+
_touch = e.gesture.pointerType === 'touch'
14+
}
15+
f(e)
16+
}
17+
718
const focus = new (mixinEventEmitter(class {
819
constructor () {
920
Hammer(window.document.body, {
1021
drag_lock_to_axis: true
1122
})
12-
.on("tap dragleft dragright dragend swipeleft swiperight", e => {
23+
.on("tap dragleft dragright dragend swipeleft swiperight", filterTouchMouse()(e => {
1324
if (sink.onGesture) sink.onGesture(e)
1425
else if (sink.emit) sink.emit('gesture', e)
15-
})
26+
}))
1627

1728
document.onkeydown = e => {
1829
if (e.keyCode === 8) {

0 commit comments

Comments
 (0)