|
|
|
@ -252,6 +252,23 @@ function wheel(e, state, context) {
@@ -252,6 +252,23 @@ function wheel(e, state, context) {
|
|
|
|
|
schedule_draw(state, context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function start_move(e, state, context) { |
|
|
|
|
// two touch identifiers are expected to be pushed into state.touch.ids at this point
|
|
|
|
|
|
|
|
|
|
geometry_clear_player(state, context, state.me); // Hide predraws of this stroke that is not means to be
|
|
|
|
|
fire_event(state, clear_event(state)); // Tell others to hide predraws of this stroke
|
|
|
|
|
|
|
|
|
|
for (const touch of e.touches) { |
|
|
|
|
const screenp = {'x': window.devicePixelRatio * touch.clientX, 'y': window.devicePixelRatio * touch.clientY}; |
|
|
|
|
|
|
|
|
|
if (touch.identifier === state.touch.ids[0]) { |
|
|
|
|
state.touch.first_finger_position = screenp; |
|
|
|
|
} else if (touch.identifier === state.touch.ids[1]) { |
|
|
|
|
state.touch.second_finger_position = screenp; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function touchstart(e, state, context) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
|
@ -270,7 +287,9 @@ function touchstart(e, state, context) {
@@ -270,7 +287,9 @@ function touchstart(e, state, context) {
|
|
|
|
|
state.touch.waiting_for_second_finger = false; |
|
|
|
|
}, config.second_finger_timeout); |
|
|
|
|
} else { |
|
|
|
|
console.error('Two touchstarts at the same time are not yet supported'); |
|
|
|
|
state.touch.ids.push(e.changedTouches[0].identifier); |
|
|
|
|
state.touch.ids.push(e.changedTouches[1].identifier); |
|
|
|
|
start_move(e, state, context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
@ -279,20 +298,8 @@ function touchstart(e, state, context) {
@@ -279,20 +298,8 @@ function touchstart(e, state, context) {
|
|
|
|
|
// There are touches already
|
|
|
|
|
if (state.touch.waiting_for_second_finger) { |
|
|
|
|
if (e.changedTouches.length === 1) { |
|
|
|
|
geometry_clear_player(state, context, state.me); // Hide predraws of this stroke that is not means to be
|
|
|
|
|
fire_event(state, clear_event(state)); // Tell others to hide predraws of this stroke
|
|
|
|
|
|
|
|
|
|
state.touch.ids.push(e.changedTouches[0].identifier); |
|
|
|
|
|
|
|
|
|
for (const touch of e.touches) { |
|
|
|
|
const screenp = {'x': window.devicePixelRatio * touch.clientX, 'y': window.devicePixelRatio * touch.clientY}; |
|
|
|
|
|
|
|
|
|
if (touch.identifier === state.touch.ids[0]) { |
|
|
|
|
state.touch.first_finger_position = screenp; |
|
|
|
|
} else if (touch.identifier === state.touch.ids[1]) { |
|
|
|
|
state.touch.second_finger_position = screenp; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
start_move(e, state, context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|