Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 19 additions & 26 deletions webui/src/js/utils/screen-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright (c) 2021, Oracle and/or its affiliates.
* Copyright (c) 2021, 2023, Oracle and/or its affiliates.
* Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
*/
'use strict';
Expand Down Expand Up @@ -32,18 +32,7 @@ define(['knockout', 'ojs/ojcorerouter'],
parentSize: vertical ? parentElement.offsetHeight : parentElement.offsetWidth
};

const percent = this.sliderPositions[name];
if (percent) {
if (vertical) {
const oneHeight = Math.round(percent * parentElement.offsetHeight);
onePane.style.height = oneHeight + 'px';
twoPane.style.height = (parentElement.offsetHeight - oneHeight) + 'px';
} else {
const oneWidth = Math.round(percent * parentElement.offsetWidth);
onePane.style.width = oneWidth + 'px';
twoPane.style.width = (parentElement.offsetWidth - oneWidth) + 'px';
}
}
resizeFromSliderPosition();

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

new ResizeObserver(() => {
// if the parent container was resized in the specified direction,
// clear any assigned heights or widths

if(lastDown) {
function resizeFromSliderPosition() {
const percent = thisUtil.sliderPositions[name];
if (percent) {
if (vertical) {
if(lastDown.parentSize !== parentElement.offsetHeight) {
onePane.style.height = null;
twoPane.style.height = null;
}
const oneHeight = Math.round(percent * parentElement.offsetHeight);
onePane.style.height = oneHeight + 'px';
twoPane.style.height = (parentElement.offsetHeight - oneHeight) + 'px';
} else {
if(lastDown.parentSize !== parentElement.offsetWidth) {
onePane.style.width = null;
twoPane.style.width = null;
}
const oneWidth = Math.round(percent * parentElement.offsetWidth);
onePane.style.width = oneWidth + 'px';
twoPane.style.width = (parentElement.offsetWidth - oneWidth) + 'px';
}
}
}

new ResizeObserver(() => {
// if the parent container was resized, resize panels based on slider position.

if(lastDown) {
resizeFromSliderPosition();
}
}).observe(parentElement);
};

Expand Down