* Changed the trigger distance between touches from 50 to 20.
* The trigger distance now takes devicePixelRatio into account.
This commit is contained in:
parent
a4ec2f5c7d
commit
cf19ad3798
|
@ -541,20 +541,25 @@ function onMouseButton(e, down) {
|
||||||
// Touch device
|
// Touch device
|
||||||
|
|
||||||
// When two touches occur within 500 ms of each other and are
|
// When two touches occur within 500 ms of each other and are
|
||||||
// closer than 50 pixels together a double click is triggered.
|
// closer than 20 pixels together a double click is triggered.
|
||||||
if (down == 1) {
|
if (down == 1) {
|
||||||
if (doubleClickTimer == null) {
|
if (doubleClickTimer == null) {
|
||||||
lastTouchPos = pos;
|
lastTouchPos = pos;
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(doubleClickTimer);
|
clearTimeout(doubleClickTimer);
|
||||||
|
|
||||||
|
// When the distance between the two touches is less than
|
||||||
|
// 20 physical pixels force the position of the latter touch
|
||||||
|
// to the position of the first.
|
||||||
|
|
||||||
var xs = lastTouchPos.x - pos.x;
|
var xs = lastTouchPos.x - pos.x;
|
||||||
var ys = lastTouchPos.y - pos.y;
|
var ys = lastTouchPos.y - pos.y;
|
||||||
var d = Math.sqrt((xs * xs) + (ys * ys));
|
var d = Math.sqrt((xs * xs) + (ys * ys));
|
||||||
|
|
||||||
// When the distance between the two touches is less than 50 pixels
|
// The devicePixelRatio is the ratio between logical pixels and
|
||||||
// force the position of the latter touch to the position of the first
|
// physical pixels. A devicePixelRatio of 2 means that the
|
||||||
if (d < 50) {
|
// physical linear resolution is double the logical resolution.
|
||||||
|
if (d < 20 * window.devicePixelRatio) {
|
||||||
pos = lastTouchPos;
|
pos = lastTouchPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue