Browse Source

Handle touchstart with 2 e.changedTouches. This fixes panning sometimes not working on iPhone

ssao
A.Olokhtonov 1 year ago
parent
commit
9a8854dc90
  1. 24
      client/index.html
  2. 35
      client/webgl_listeners.js

24
client/index.html

@ -7,20 +7,20 @@ @@ -7,20 +7,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="shortcut icon" href="icons/favicon.svg" id="favicon">
<link rel="stylesheet" type="text/css" href="default.css?v=57">
<link rel="stylesheet" type="text/css" href="default.css?v=58">
<script type="text/javascript" src="aux.js?v=57"></script>
<script type="text/javascript" src="math.js?v=57"></script>
<script type="text/javascript" src="tools.js?v=57"></script>
<script type="text/javascript" src="webgl_geometry.js?v=57"></script>
<script type="text/javascript" src="webgl_shaders.js?v=57"></script>
<script type="text/javascript" src="webgl_listeners.js?v=57"></script>
<script type="text/javascript" src="webgl_draw.js?v=57"></script>
<script type="text/javascript" src="index.js?v=57"></script>
<script type="text/javascript" src="aux.js?v=58"></script>
<script type="text/javascript" src="math.js?v=58"></script>
<script type="text/javascript" src="tools.js?v=58"></script>
<script type="text/javascript" src="webgl_geometry.js?v=58"></script>
<script type="text/javascript" src="webgl_shaders.js?v=58"></script>
<script type="text/javascript" src="webgl_listeners.js?v=58"></script>
<script type="text/javascript" src="webgl_draw.js?v=58"></script>
<script type="text/javascript" src="index.js?v=58"></script>
<script type="text/javascript" src="client_send.js?v=57"></script>
<script type="text/javascript" src="client_recv.js?v=57"></script>
<script type="text/javascript" src="websocket.js?v=57"></script>
<script type="text/javascript" src="client_send.js?v=58"></script>
<script type="text/javascript" src="client_recv.js?v=58"></script>
<script type="text/javascript" src="websocket.js?v=58"></script>
</head>
<body>
<div class="main">

35
client/webgl_listeners.js

@ -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;

Loading…
Cancel
Save