|
1 | 1 | /**
|
2 | 2 | * @license
|
3 |
| - * Copyright (c) 2021, Oracle and/or its affiliates. |
| 3 | + * Copyright (c) 2021, 2023, Oracle and/or its affiliates. |
4 | 4 | * Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
|
5 | 5 | */
|
6 | 6 | 'use strict';
|
@@ -32,18 +32,7 @@ define(['knockout', 'ojs/ojcorerouter'],
|
32 | 32 | parentSize: vertical ? parentElement.offsetHeight : parentElement.offsetWidth
|
33 | 33 | };
|
34 | 34 |
|
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(); |
47 | 36 |
|
48 | 37 | slider.onmousedown = (e => {
|
49 | 38 | lastDown = {
|
@@ -84,23 +73,27 @@ define(['knockout', 'ojs/ojcorerouter'],
|
84 | 73 | window.api.ipc.send('set-divider-location', name, mouseUpPercent);
|
85 | 74 | }
|
86 | 75 |
|
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) { |
92 | 79 | 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'; |
97 | 83 | } 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'; |
102 | 87 | }
|
103 | 88 | }
|
| 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 | + } |
104 | 97 | }).observe(parentElement);
|
105 | 98 | };
|
106 | 99 |
|
|
0 commit comments