|
|
@ -666,6 +666,7 @@ function touchstart(e, state, context) { |
|
|
|
canvasp.pressure = 128; // TODO: check out touch devices' e.pressure
|
|
|
|
canvasp.pressure = 128; // TODO: check out touch devices' e.pressure
|
|
|
|
geometry_start_prestroke(state, state.me); |
|
|
|
geometry_start_prestroke(state, state.me); |
|
|
|
geometry_add_prepoint(state, context, state.me, canvasp, e.pointerType === "pen"); |
|
|
|
geometry_add_prepoint(state, context, state.me, canvasp, e.pointerType === "pen"); |
|
|
|
|
|
|
|
state.touch.waiting_for_second_finger = true; |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
state.touch.waiting_for_second_finger = false; |
|
|
|
state.touch.waiting_for_second_finger = false; |
|
|
|
}, config.second_finger_timeout); |
|
|
|
}, config.second_finger_timeout); |
|
|
@ -676,7 +677,7 @@ function touchstart(e, state, context) { |
|
|
|
'y': screenp.y, |
|
|
|
'y': screenp.y, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: @touch, remove preview
|
|
|
|
geometry_clear_newest_prestroke(state, context, state.me); |
|
|
|
fire_event(state, clear_event(state)); // Tell others to hide predraws of this stroke
|
|
|
|
fire_event(state, clear_event(state)); // Tell others to hide predraws of this stroke
|
|
|
|
state.touch.drawing = false; |
|
|
|
state.touch.drawing = false; |
|
|
|
state.touch.moving = true; |
|
|
|
state.touch.moving = true; |
|
|
@ -695,13 +696,6 @@ function touchmove(e, state, context) { |
|
|
|
const screenp = {'x': window.devicePixelRatio * e.clientX, 'y': window.devicePixelRatio * e.clientY}; |
|
|
|
const screenp = {'x': window.devicePixelRatio * e.clientX, 'y': window.devicePixelRatio * e.clientY}; |
|
|
|
const canvasp = screen_to_canvas(state, screenp); |
|
|
|
const canvasp = screen_to_canvas(state, screenp); |
|
|
|
|
|
|
|
|
|
|
|
state.touch.moves += 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (state.touch.moves > config.buffer_first_touchmoves) { |
|
|
|
|
|
|
|
// At this point touch with second finger will NOT start a pan
|
|
|
|
|
|
|
|
state.touch.waiting_for_second_finger = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
canvasp.pressure = 128; // TODO: check out touch devices' e.pressure
|
|
|
|
canvasp.pressure = 128; // TODO: check out touch devices' e.pressure
|
|
|
|
geometry_add_prepoint(state, context, state.me, canvasp, false); |
|
|
|
geometry_add_prepoint(state, context, state.me, canvasp, false); |
|
|
|
fire_event(state, predraw_event(canvasp.x, canvasp.y)); |
|
|
|
fire_event(state, predraw_event(canvasp.x, canvasp.y)); |
|
|
@ -714,11 +708,14 @@ function touchmove(e, state, context) { |
|
|
|
if (state.touch.moving) { |
|
|
|
if (state.touch.moving) { |
|
|
|
if (state.touch.events.length === 1) { |
|
|
|
if (state.touch.events.length === 1) { |
|
|
|
// Simplified move with one finger
|
|
|
|
// Simplified move with one finger
|
|
|
|
state.canvas.offset.x += e.movementX; |
|
|
|
const old_f1 = {...state.touch.events[0]}; |
|
|
|
state.canvas.offset.y += e.movementY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state.touch.events[0].x = e.clientX * window.devicePixelRatio; |
|
|
|
state.touch.events[0].x = e.clientX * window.devicePixelRatio; |
|
|
|
state.touch.events[0].y = e.clientX * window.devicePixelRatio; |
|
|
|
state.touch.events[0].y = e.clientY * window.devicePixelRatio; |
|
|
|
|
|
|
|
const new_f1 = state.touch.events[0]; |
|
|
|
|
|
|
|
const dx = new_f1.x - old_f1.x; |
|
|
|
|
|
|
|
const dy = new_f1.y - old_f1.y; |
|
|
|
|
|
|
|
state.canvas.offset.x += dx; |
|
|
|
|
|
|
|
state.canvas.offset.y += dy; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const old_f1 = {...state.touch.events[0]}; |
|
|
|
const old_f1 = {...state.touch.events[0]}; |
|
|
|
const old_f2 = {...state.touch.events[1]}; |
|
|
|
const old_f2 = {...state.touch.events[1]}; |
|
|
@ -757,9 +754,9 @@ function touchmove(e, state, context) { |
|
|
|
state.canvas.offset.y += dy; |
|
|
|
state.canvas.offset.y += dy; |
|
|
|
|
|
|
|
|
|
|
|
const scale_by = new_finger_distance / old_finger_distance; |
|
|
|
const scale_by = new_finger_distance / old_finger_distance; |
|
|
|
const dz = state.canvas.zoom * (scale_by - 1.0); |
|
|
|
const zc = old_finger_midpoint; |
|
|
|
|
|
|
|
|
|
|
|
const zc = old_finger_midpoint_canvas; |
|
|
|
state.canvas.zoom = state.canvas.target_zoom = old_zoom * scale_by; |
|
|
|
state.canvas.offset.x = zc.x - (zc.x - state.canvas.offset.x) * state.canvas.zoom / old_zoom; |
|
|
|
state.canvas.offset.x = zc.x - (zc.x - state.canvas.offset.x) * state.canvas.zoom / old_zoom; |
|
|
|
state.canvas.offset.y = zc.y - (zc.y - state.canvas.offset.y) * state.canvas.zoom / old_zoom; |
|
|
|
state.canvas.offset.y = zc.y - (zc.y - state.canvas.offset.y) * state.canvas.zoom / old_zoom; |
|
|
|
} |
|
|
|
} |
|
|
|