mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
Fix non-left mouse button clicks (there may not be one touchstart event per touch). Fix setting/resetting of gesture_in_progress
flag.
This commit is contained in:
@@ -163,7 +163,6 @@ Guacamole.Mouse = function(element) {
|
|||||||
var last_touch_y = 0;
|
var last_touch_y = 0;
|
||||||
var last_touch_time = 0;
|
var last_touch_time = 0;
|
||||||
var pixels_moved = 0;
|
var pixels_moved = 0;
|
||||||
var touch_distance = 0;
|
|
||||||
|
|
||||||
var touch_buttons = {
|
var touch_buttons = {
|
||||||
1: "left",
|
1: "left",
|
||||||
@@ -176,11 +175,11 @@ Guacamole.Mouse = function(element) {
|
|||||||
|
|
||||||
element.addEventListener("touchend", function(e) {
|
element.addEventListener("touchend", function(e) {
|
||||||
|
|
||||||
|
cancelEvent(e);
|
||||||
|
|
||||||
// If we're handling a gesture AND this is the last touch
|
// If we're handling a gesture AND this is the last touch
|
||||||
if (gesture_in_progress && e.touches.length == 0) {
|
if (gesture_in_progress && e.touches.length == 0) {
|
||||||
|
|
||||||
cancelEvent(e);
|
|
||||||
|
|
||||||
var time = new Date().getTime();
|
var time = new Date().getTime();
|
||||||
|
|
||||||
// Get corresponding mouse button
|
// Get corresponding mouse button
|
||||||
@@ -220,37 +219,41 @@ Guacamole.Mouse = function(element) {
|
|||||||
if (guac_mouse.onmouseup)
|
if (guac_mouse.onmouseup)
|
||||||
guac_mouse.onmouseup(guac_mouse.currentState);
|
guac_mouse.onmouseup(guac_mouse.currentState);
|
||||||
|
|
||||||
// Allow mouse events now that touching is over
|
// Gesture now over
|
||||||
gesture_in_progress = false;
|
gesture_in_progress = false;
|
||||||
|
|
||||||
}, guac_mouse.clickTimingThreshold);
|
}, guac_mouse.clickTimingThreshold);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're not waiting to see if this is a click, stop gesture
|
||||||
|
if (!click_release_timeout)
|
||||||
|
gesture_in_progress = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
element.addEventListener("touchstart", function(e) {
|
element.addEventListener("touchstart", function(e) {
|
||||||
|
|
||||||
|
cancelEvent(e);
|
||||||
|
|
||||||
// Track number of touches, but no more than three
|
// Track number of touches, but no more than three
|
||||||
touch_count = Math.min(e.touches.length, 3);
|
touch_count = Math.min(e.touches.length, 3);
|
||||||
|
|
||||||
|
// Clear timeout, if set
|
||||||
|
if (click_release_timeout) {
|
||||||
|
window.clearTimeout(click_release_timeout);
|
||||||
|
click_release_timeout = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Record initial touch location and time for touch movement
|
// Record initial touch location and time for touch movement
|
||||||
// and tap gestures
|
// and tap gestures
|
||||||
if (e.touches.length == 1) {
|
if (!gesture_in_progress) {
|
||||||
|
|
||||||
cancelEvent(e);
|
|
||||||
|
|
||||||
// Stop mouse events while touching
|
// Stop mouse events while touching
|
||||||
gesture_in_progress = true;
|
gesture_in_progress = true;
|
||||||
|
|
||||||
// Clear timeout, if set
|
|
||||||
if (click_release_timeout) {
|
|
||||||
window.clearTimeout(click_release_timeout);
|
|
||||||
click_release_timeout = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Record touch location and time
|
// Record touch location and time
|
||||||
var starting_touch = e.touches[0];
|
var starting_touch = e.touches[0];
|
||||||
last_touch_x = starting_touch.clientX;
|
last_touch_x = starting_touch.clientX;
|
||||||
|
Reference in New Issue
Block a user