mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-10 23:21:21 +00:00
GUAC-1244: Replace timeout with better line/page constants. Reset scroll_delta so the delta doesn't have to evenly divide into scrollThreshold.
This commit is contained in:
@@ -39,12 +39,6 @@ Guacamole.Mouse = function(element) {
|
|||||||
*/
|
*/
|
||||||
var guac_mouse = this;
|
var guac_mouse = this;
|
||||||
|
|
||||||
/**
|
|
||||||
* Timeout before a single mouse scroll happens.
|
|
||||||
* @type Number
|
|
||||||
*/
|
|
||||||
var mouse_scroll_timeout = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of mousemove events to require before re-enabling mouse
|
* The number of mousemove events to require before re-enabling mouse
|
||||||
* event handling after receiving a touch event.
|
* event handling after receiving a touch event.
|
||||||
@@ -55,17 +49,17 @@ Guacamole.Mouse = function(element) {
|
|||||||
* The minimum amount of pixels scrolled required for a single scroll button
|
* The minimum amount of pixels scrolled required for a single scroll button
|
||||||
* click.
|
* click.
|
||||||
*/
|
*/
|
||||||
this.scrollThreshold = 120;
|
this.scrollThreshold = 53;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of pixels to scroll per line.
|
* The number of pixels to scroll per line.
|
||||||
*/
|
*/
|
||||||
this.PIXELS_PER_LINE = 40;
|
this.PIXELS_PER_LINE = 18;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of pixels to scroll per page.
|
* The number of pixels to scroll per page.
|
||||||
*/
|
*/
|
||||||
this.PIXELS_PER_PAGE = 640;
|
this.PIXELS_PER_PAGE = this.PIXELS_PER_LINE * 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current mouse state. The properties of this state are updated when
|
* The current mouse state. The properties of this state are updated when
|
||||||
@@ -279,13 +273,10 @@ Guacamole.Mouse = function(element) {
|
|||||||
// Update overall delta
|
// Update overall delta
|
||||||
scroll_delta += delta;
|
scroll_delta += delta;
|
||||||
|
|
||||||
if (mouse_scroll_timeout === null) {
|
|
||||||
|
|
||||||
// Send actual mouse scroll event after a threshold
|
|
||||||
mouse_scroll_timeout = window.setTimeout(function () {
|
|
||||||
|
|
||||||
// Up
|
// Up
|
||||||
if (scroll_delta < 0) {
|
if (scroll_delta <= -guac_mouse.scrollThreshold) {
|
||||||
|
|
||||||
|
// Repeatedly click the up button until insufficient delta remains
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if (guac_mouse.onmousedown) {
|
if (guac_mouse.onmousedown) {
|
||||||
@@ -300,11 +291,17 @@ Guacamole.Mouse = function(element) {
|
|||||||
|
|
||||||
scroll_delta += guac_mouse.scrollThreshold;
|
scroll_delta += guac_mouse.scrollThreshold;
|
||||||
|
|
||||||
} while (scroll_delta < 0);
|
} while (scroll_delta <= -guac_mouse.scrollThreshold);
|
||||||
|
|
||||||
|
// Reset delta
|
||||||
|
scroll_delta = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Down
|
// Down
|
||||||
else if (scroll_delta > 0) {
|
if (scroll_delta >= guac_mouse.scrollThreshold) {
|
||||||
|
|
||||||
|
// Repeatedly click the down button until insufficient delta remains
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if (guac_mouse.onmousedown) {
|
if (guac_mouse.onmousedown) {
|
||||||
@@ -319,14 +316,11 @@ Guacamole.Mouse = function(element) {
|
|||||||
|
|
||||||
scroll_delta -= guac_mouse.scrollThreshold;
|
scroll_delta -= guac_mouse.scrollThreshold;
|
||||||
|
|
||||||
} while (scroll_delta > 0);
|
} while (scroll_delta >= guac_mouse.scrollThreshold);
|
||||||
}
|
|
||||||
|
|
||||||
|
// Reset delta
|
||||||
scroll_delta = 0;
|
scroll_delta = 0;
|
||||||
window.clearTimeout(mouse_scroll_timeout);
|
|
||||||
mouse_scroll_timeout = null;
|
|
||||||
|
|
||||||
}, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelEvent(e);
|
cancelEvent(e);
|
||||||
|
Reference in New Issue
Block a user