Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4a527ec

Browse files
Adjust slider panel sizes when container is resized (#216)
1 parent 50dd192 commit 4a527ec

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

‎webui/src/js/utils/screen-utils.js‎

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
* Copyright (c) 2021, 2023, Oracle and/or its affiliates.
44
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
'use strict';
@@ -32,18 +32,7 @@ define(['knockout', 'ojs/ojcorerouter'],
3232
parentSize: vertical ? parentElement.offsetHeight : parentElement.offsetWidth
3333
};
3434

35-
const percent = this.sliderPositions[name];
36-
if (percent) {
37-
if (vertical) {
38-
const oneHeight = Math.round(percent * parentElement.offsetHeight);
39-
onePane.style.height = oneHeight + 'px';
40-
twoPane.style.height = (parentElement.offsetHeight - oneHeight) + 'px';
41-
} else {
42-
const oneWidth = Math.round(percent * parentElement.offsetWidth);
43-
onePane.style.width = oneWidth + 'px';
44-
twoPane.style.width = (parentElement.offsetWidth - oneWidth) + 'px';
45-
}
46-
}
35+
resizeFromSliderPosition();
4736

4837
slider.onmousedown = (e => {
4938
lastDown = {
@@ -84,23 +73,27 @@ define(['knockout', 'ojs/ojcorerouter'],
8473
window.api.ipc.send('set-divider-location', name, mouseUpPercent);
8574
}
8675

87-
new ResizeObserver(() => {
88-
// if the parent container was resized in the specified direction,
89-
// clear any assigned heights or widths
90-
91-
if(lastDown) {
76+
function resizeFromSliderPosition() {
77+
const percent = thisUtil.sliderPositions[name];
78+
if (percent) {
9279
if (vertical) {
93-
if(lastDown.parentSize !== parentElement.offsetHeight) {
94-
onePane.style.height = null;
95-
twoPane.style.height = null;
96-
}
80+
const oneHeight = Math.round(percent * parentElement.offsetHeight);
81+
onePane.style.height = oneHeight + 'px';
82+
twoPane.style.height = (parentElement.offsetHeight - oneHeight) + 'px';
9783
} else {
98-
if(lastDown.parentSize !== parentElement.offsetWidth) {
99-
onePane.style.width = null;
100-
twoPane.style.width = null;
101-
}
84+
const oneWidth = Math.round(percent * parentElement.offsetWidth);
85+
onePane.style.width = oneWidth + 'px';
86+
twoPane.style.width = (parentElement.offsetWidth - oneWidth) + 'px';
10287
}
10388
}
89+
}
90+
91+
new ResizeObserver(() => {
92+
// if the parent container was resized, resize panels based on slider position.
93+
94+
if(lastDown) {
95+
resizeFromSliderPosition();
96+
}
10497
}).observe(parentElement);
10598
};
10699

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /