mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 17:54:20 +02:00
Prevent users window from being dragged offscreen
This commit is contained in:
parent
34042d51ad
commit
0ad7aa72fb
1 changed files with 10 additions and 1 deletions
|
@ -344,6 +344,7 @@ var usersWindow = (function () {
|
|||
windowTextHeight,
|
||||
windowLineSpacing,
|
||||
windowLineHeight, // = windowTextHeight + windowLineSpacing
|
||||
windowMinimumHeight,
|
||||
|
||||
usersOnline, // Raw users data
|
||||
linesOfUsers = [], // Array of indexes pointing into usersOnline
|
||||
|
@ -435,6 +436,11 @@ var usersWindow = (function () {
|
|||
}
|
||||
}
|
||||
|
||||
function saturateWindowPosition() {
|
||||
windowPosition.x = Math.max(0, Math.min(viewport.x - WINDOW_WIDTH, windowPosition.x));
|
||||
windowPosition.y = Math.max(windowMinimumHeight, Math.min(viewport.y, windowPosition.y));
|
||||
}
|
||||
|
||||
function updateOverlayPositions() {
|
||||
// Overlay positions are all relative to windowPosition; windowPosition is the position of the windowPane overlay.
|
||||
var windowLeft = windowPosition.x,
|
||||
|
@ -854,6 +860,8 @@ var usersWindow = (function () {
|
|||
x: event.x - movingClickOffset.x,
|
||||
y: event.y - movingClickOffset.y
|
||||
};
|
||||
|
||||
saturateWindowPosition();
|
||||
calculateWindowHeight();
|
||||
updateOverlayPositions();
|
||||
updateUsersDisplay();
|
||||
|
@ -947,6 +955,7 @@ var usersWindow = (function () {
|
|||
windowTextHeight = Math.floor(Overlays.textSize(textSizeOverlay, "1").height);
|
||||
windowLineSpacing = Math.floor(Overlays.textSize(textSizeOverlay, "1\n2").height - 2 * windowTextHeight);
|
||||
windowLineHeight = windowTextHeight + windowLineSpacing;
|
||||
windowMinimumHeight = windowTextHeight + WINDOW_MARGIN + WINDOW_BASE_MARGIN;
|
||||
Overlays.deleteOverlay(textSizeOverlay);
|
||||
|
||||
viewport = Controller.getViewportDimensions();
|
||||
|
@ -958,7 +967,6 @@ var usersWindow = (function () {
|
|||
if (offset.hasOwnProperty("x") && offset.hasOwnProperty("y")) {
|
||||
windowPosition.x = offset.x < 0 ? viewport.x + offset.x : offset.x;
|
||||
windowPosition.y = offset.y <= 0 ? viewport.y + offset.y : offset.y;
|
||||
|
||||
} else {
|
||||
hmdViewport = Controller.getRecommendedOverlayRect();
|
||||
windowPosition = {
|
||||
|
@ -967,6 +975,7 @@ var usersWindow = (function () {
|
|||
};
|
||||
}
|
||||
|
||||
saturateWindowPosition();
|
||||
calculateWindowHeight();
|
||||
|
||||
windowBorder = Overlays.addOverlay("rectangle", {
|
||||
|
|
Loading…
Reference in a new issue