mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
Simplify autoscroll.
This commit is contained in:
@@ -476,28 +476,18 @@ GuacamoleUI.attach = function(guac) {
|
|||||||
var view_width = GuacamoleUI.viewport.offsetWidth;
|
var view_width = GuacamoleUI.viewport.offsetWidth;
|
||||||
var view_height = GuacamoleUI.viewport.offsetHeight;
|
var view_height = GuacamoleUI.viewport.offsetHeight;
|
||||||
|
|
||||||
// Determine scroll amounts based on mouse position relative to document
|
// Scroll horizontally if necessary
|
||||||
|
|
||||||
var scroll_amount_x;
|
|
||||||
if (mouse_view_x > view_width)
|
if (mouse_view_x > view_width)
|
||||||
scroll_amount_x = mouse_view_x - view_width;
|
GuacamoleUI.viewport.scrollLeft += mouse_view_x - view_width;
|
||||||
else if (mouse_view_x < 0)
|
else if (mouse_view_x < 0)
|
||||||
scroll_amount_x = mouse_view_x;
|
GuacamoleUI.viewport.scrollLeft += mouse_view_x;
|
||||||
else
|
|
||||||
scroll_amount_x = 0;
|
|
||||||
|
|
||||||
var scroll_amount_y;
|
// Scroll vertically if necessary
|
||||||
if (mouse_view_y > view_height)
|
if (mouse_view_y > view_height)
|
||||||
scroll_amount_y = mouse_view_y - view_height;
|
GuacamoleUI.viewport.scrollTop += mouse_view_y - view_height;
|
||||||
else if (mouse_view_y < 0)
|
else if (mouse_view_y < 0)
|
||||||
scroll_amount_y = mouse_view_y;
|
GuacamoleUI.viewport.scrollTop += mouse_view_y;
|
||||||
else
|
|
||||||
scroll_amount_y = 0;
|
|
||||||
|
|
||||||
// Scroll (if necessary) to keep mouse on screen.
|
|
||||||
GuacamoleUI.viewport.scrollLeft += scroll_amount_x;
|
|
||||||
GuacamoleUI.viewport.scrollTop += scroll_amount_y;
|
|
||||||
|
|
||||||
// Send mouse event
|
// Send mouse event
|
||||||
guac.sendMouseState(mouseState);
|
guac.sendMouseState(mouseState);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user