You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that completing the line with a mouse click twice on the same vertex is a precisely triggered operation and works great.
Note that completing the line with a touch device often happens prematurely. This happens because multiple touchStart messages often happen within the 25 pixel touchBuffer quite accidentally in the course of attempting to make a single tap. Reducing the size of touchBuffer slightly improves the situation, but it is still a significant problem on an iPhone 13, and presumably most touch devices.
Expected Behavior
Drawing lines should work on touch devices.
Actual Behavior
Drawing lines terminates prematurely in ~25% of attempts.
Diagnosis
In draw_line_string.js line drawing completion is handled identically for both mouse click and touch.
I believe that to solve this problem, a debounce needs to be applied to only the onTap path, so that additional taps within (say) 300mS of the first tap are ignored.
The text was updated successfully, but these errors were encountered:
I tried adding the following tap debounce code to draw_line_string.js and it seems to have completely solved the problem:
DrawLineString.lastTapTime = Date.now();
DrawLineString.onTap = function (state, e) {
const now = Date.now();
const tapDebounceTimeMS = 300;
if (now - this.lastTapTime < tapDebounceTimeMS) {
return;
}
this.lastTapTime = now;
if (CommonSelectors.isVertex(e)) return this.clickOnVertex(state, e);
this.clickAnywhere(state, e);
};
To get tests to run, I had to add a 400mS delay immediately before every instance of touchTap(...) in draw_line_string.test.js. I'm sure my naive sleep() below isn't the best solution, but I don't really understand how to best implement such a delay within the testing framework:
const tapDebounceDelayMS = 400;
function sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
mapbox-gl-js version: 3.1.2
mapbox-gl-draw version: 1.4.3
Steps to Trigger Behavior
touchStart
messages often happen within the 25 pixeltouchBuffer
quite accidentally in the course of attempting to make a single tap. Reducing the size oftouchBuffer
slightly improves the situation, but it is still a significant problem on an iPhone 13, and presumably most touch devices.Expected Behavior
Drawing lines should work on touch devices.
Actual Behavior
Drawing lines terminates prematurely in ~25% of attempts.
Diagnosis
In
draw_line_string.js
line drawing completion is handled identically for both mouse click and touch.I believe that to solve this problem, a debounce needs to be applied to only the
onTap
path, so that additional taps within (say) 300mS of the first tap are ignored.The text was updated successfully, but these errors were encountered: