Skip to content

Commit cfa7e23

Browse files
committed
Fix the selectable positioning and sizing issues in Explore. All set!
1 parent e1f52eb commit cfa7e23

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/gui/src/UI/UIWindow.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,8 @@ async function UIWindow(options) {
12741274
// only for Desktop screens
12751275
// --------------------------------------------------------
12761276
let selection_area = null;
1277+
let initial_body_scroll_width = 0;
1278+
let initial_body_scroll_height = 0;
12771279
if(options.is_dir && options.selectable_body && !isMobile.phone && !isMobile.tablet){
12781280
let selected_ctrl_items = [];
12791281

@@ -1324,16 +1326,16 @@ async function UIWindow(options) {
13241326
const windowBodyRect = el_window_body.getBoundingClientRect();
13251327

13261328
// Get the window body's content dimensions
1327-
const windowBodyWidth = el_window_body.scrollWidth;
1328-
const windowBodyHeight = el_window_body.scrollHeight;
1329+
initial_body_scroll_width = el_window_body.scrollWidth ;
1330+
initial_body_scroll_height = el_window_body.scrollHeight;
13291331

13301332
// Calculate position relative to the window body (accounting for scroll)
13311333
let relativeX = window.mouseX - windowBodyRect.left + scrollLeft;
13321334
let relativeY = window.mouseY - windowBodyRect.top + scrollTop;
13331335

13341336
// Constrain initial position to window body content bounds
1335-
relativeX = Math.max(0, Math.min(windowBodyWidth, relativeX));
1336-
relativeY = Math.max(0, Math.min(windowBodyHeight, relativeY));
1337+
relativeX = Math.max(0, Math.min(initial_body_scroll_width, relativeX));
1338+
relativeY = Math.max(0, Math.min(initial_body_scroll_height, relativeY));
13371339

13381340
$(selection_area).css({
13391341
'position': 'absolute',
@@ -1396,8 +1398,8 @@ async function UIWindow(options) {
13961398
let top = constrainedMouseY < selection_area_start_y ? constrainedMouseY : selection_area_start_y;
13971399

13981400
// Ensure selection area doesn't go outside window body content bounds
1399-
left = Math.max(0, Math.min(windowBodyWidth - width, left));
1400-
top = Math.max(0, Math.min(windowBodyHeight - height, top));
1401+
left = Math.max(0, Math.min(initial_body_scroll_width - width, left));
1402+
top = Math.max(0, Math.min(initial_body_scroll_height - height, top));
14011403

14021404
// update selection area size and position for bidirectional expansion
14031405
$(selection_area).css({

0 commit comments

Comments
 (0)