mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Clean up Mouse.js a bit.
This commit is contained in:
@@ -199,7 +199,7 @@ Guacamole.Mouse = function(element) {
|
|||||||
|
|
||||||
// Check that mouseout is due to actually LEAVING the element
|
// Check that mouseout is due to actually LEAVING the element
|
||||||
var target = e.relatedTarget || e.toElement;
|
var target = e.relatedTarget || e.toElement;
|
||||||
while (target != null) {
|
while (target !== null) {
|
||||||
if (target === element)
|
if (target === element)
|
||||||
return;
|
return;
|
||||||
target = target.parentNode;
|
target = target.parentNode;
|
||||||
@@ -349,7 +349,7 @@ Guacamole.Mouse.State = function(x, y, left, middle, right, up, down) {
|
|||||||
* Whether the middle mouse button is currently pressed.
|
* Whether the middle mouse button is currently pressed.
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
this.middle = middle
|
this.middle = middle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the right mouse button is currently pressed.
|
* Whether the right mouse button is currently pressed.
|
||||||
@@ -511,7 +511,7 @@ Guacamole.Mouse.Touchpad = function(element) {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// 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) {
|
||||||
|
|
||||||
var time = new Date().getTime();
|
var time = new Date().getTime();
|
||||||
|
|
||||||
@@ -613,7 +613,7 @@ Guacamole.Mouse.Touchpad = function(element) {
|
|||||||
pixels_moved += Math.abs(delta_x) + Math.abs(delta_y);
|
pixels_moved += Math.abs(delta_x) + Math.abs(delta_y);
|
||||||
|
|
||||||
// If only one touch involved, this is mouse move
|
// If only one touch involved, this is mouse move
|
||||||
if (touch_count == 1) {
|
if (touch_count === 1) {
|
||||||
|
|
||||||
// Calculate average velocity in Manhatten pixels per millisecond
|
// Calculate average velocity in Manhatten pixels per millisecond
|
||||||
var velocity = pixels_moved / (new Date().getTime() - last_touch_time);
|
var velocity = pixels_moved / (new Date().getTime() - last_touch_time);
|
||||||
@@ -648,7 +648,7 @@ Guacamole.Mouse.Touchpad = function(element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Interpret two-finger swipe as scrollwheel
|
// Interpret two-finger swipe as scrollwheel
|
||||||
else if (touch_count == 2) {
|
else if (touch_count === 2) {
|
||||||
|
|
||||||
// If change in location passes threshold for scroll
|
// If change in location passes threshold for scroll
|
||||||
if (Math.abs(delta_y) >= guac_touchpad.scrollThreshold) {
|
if (Math.abs(delta_y) >= guac_touchpad.scrollThreshold) {
|
||||||
@@ -753,7 +753,7 @@ Guacamole.Mouse.Touchscreen = function(element) {
|
|||||||
element.addEventListener("touchend", function(e) {
|
element.addEventListener("touchend", function(e) {
|
||||||
|
|
||||||
// Ignore if more than one touch
|
// Ignore if more than one touch
|
||||||
if (e.touches.length + e.changedTouches.length != 1)
|
if (e.touches.length + e.changedTouches.length !== 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -763,7 +763,7 @@ Guacamole.Mouse.Touchscreen = function(element) {
|
|||||||
guac_touchscreen.currentState.left = false;
|
guac_touchscreen.currentState.left = false;
|
||||||
|
|
||||||
// Fire release event when the last touch is released, if event defined
|
// Fire release event when the last touch is released, if event defined
|
||||||
if (e.touches.length == 0 && guac_touchscreen.onmouseup)
|
if (e.touches.length === 0 && guac_touchscreen.onmouseup)
|
||||||
guac_touchscreen.onmouseup(guac_touchscreen.currentState);
|
guac_touchscreen.onmouseup(guac_touchscreen.currentState);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
@@ -771,7 +771,7 @@ Guacamole.Mouse.Touchscreen = function(element) {
|
|||||||
element.addEventListener("touchstart", function(e) {
|
element.addEventListener("touchstart", function(e) {
|
||||||
|
|
||||||
// Ignore if more than one touch
|
// Ignore if more than one touch
|
||||||
if (e.touches.length != 1)
|
if (e.touches.length !== 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -793,7 +793,7 @@ Guacamole.Mouse.Touchscreen = function(element) {
|
|||||||
element.addEventListener("touchmove", function(e) {
|
element.addEventListener("touchmove", function(e) {
|
||||||
|
|
||||||
// Ignore if more than one touch
|
// Ignore if more than one touch
|
||||||
if (e.touches.length != 1)
|
if (e.touches.length !== 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
Reference in New Issue
Block a user