Fixes panel resizing issue where resizing window to be smaller would commit panel width to smaller width and not re-expand after window is expanded

This commit is contained in:
Mo Bitar
2019-04-01 12:03:31 -05:00
parent 9449ec5ca2
commit 5ad3904cf5
2 changed files with 20 additions and 18 deletions

View File

@@ -525,17 +525,19 @@ angular.module('app')
this.leftResizeControl = {}; this.leftResizeControl = {};
this.rightResizeControl = {}; this.rightResizeControl = {};
this.onPanelResizeFinish = function(width, left, isMaxWidth) { this.onPanelResizeFinish = (width, left, isMaxWidth) => {
if(isMaxWidth) { if(isMaxWidth) {
authManager.setUserPrefValue("editorWidth", null); authManager.setUserPrefValue("editorWidth", null);
} else { } else {
if(width !== undefined && width !== null) { if(width !== undefined && width !== null) {
authManager.setUserPrefValue("editorWidth", width); authManager.setUserPrefValue("editorWidth", width);
this.leftResizeControl.setWidth(width);
} }
} }
if(left !== undefined && left !== null) { if(left !== undefined && left !== null) {
authManager.setUserPrefValue("editorLeft", left); authManager.setUserPrefValue("editorLeft", left);
this.rightResizeControl.setLeft(left);
} }
authManager.syncUserPreferences(); authManager.syncUserPreferences();
} }
@@ -560,11 +562,13 @@ angular.module('app')
let width = authManager.getUserPrefValue("editorWidth", null); let width = authManager.getUserPrefValue("editorWidth", null);
if(width !== null) { if(width !== null) {
this.leftResizeControl.setWidth(width); this.leftResizeControl.setWidth(width);
this.rightResizeControl.setWidth(width);
} }
let left = authManager.getUserPrefValue("editorLeft", null); let left = authManager.getUserPrefValue("editorLeft", null);
if(left !== null) { if(left !== null) {
this.leftResizeControl.setLeft(left); this.leftResizeControl.setLeft(left);
this.rightResizeControl.setLeft(left);
} }
} }
} }

View File

@@ -50,9 +50,17 @@ class PanelResizer {
let resizerWidth = resizerColumn.offsetWidth; let resizerWidth = resizerColumn.offsetWidth;
let minWidth = $scope.minWidth || resizerWidth; let minWidth = $scope.minWidth || resizerWidth;
var pressed = false; var pressed = false;
var startWidth = panel.scrollWidth, startX = 0, lastDownX = 0, collapsed, lastWidth = startWidth, startLeft, lastLeft; var startWidth = panel.scrollWidth, startX = 0, lastDownX = 0, collapsed, lastWidth = startWidth, startLeft = panel.offsetLeft, lastLeft = startLeft;
var appFrame; var appFrame;
$scope.isAtMaxWidth = function() {
return Math.round((lastWidth + lastLeft)) == Math.round(getParentRect().width);
}
$scope.isCollapsed = function() {
return lastWidth <= minWidth;
}
// Handle Double Click Event // Handle Double Click Event
var widthBeforeLastDblClick = 0; var widthBeforeLastDblClick = 0;
resizerColumn.ondblclick = () => { resizerColumn.ondblclick = () => {
@@ -91,7 +99,8 @@ class PanelResizer {
} }
function reloadDefaultValues() { function reloadDefaultValues() {
startWidth = panel.scrollWidth; startWidth = $scope.isAtMaxWidth() ? getParentRect().width : panel.scrollWidth;
lastWidth = startWidth;
appFrame = document.getElementById("app").getBoundingClientRect(); appFrame = document.getElementById("app").getBoundingClientRect();
} }
reloadDefaultValues(); reloadDefaultValues();
@@ -120,9 +129,9 @@ class PanelResizer {
width = maxWidth; width = maxWidth;
} }
if(width == parentRect.width) { if((Math.round(width + lastLeft)) == Math.round(parentRect.width)) {
panel.style.width = "100%"; panel.style.width = `calc(100% - ${lastLeft}px)`;
panel.style.flexBasis = "100%"; panel.style.flexBasis = `calc(100% - ${lastLeft}px)`;
} else { } else {
panel.style.flexBasis = width + "px"; panel.style.flexBasis = width + "px";
panel.style.width = width + "px"; panel.style.width = width + "px";
@@ -135,14 +144,6 @@ class PanelResizer {
} }
} }
$scope.isCollapsed = function() {
return lastWidth <= minWidth;
}
$scope.isAtMaxWidth = function() {
return lastWidth == getParentRect().width;
}
$scope.setLeft = function(left) { $scope.setLeft = function(left) {
panel.style.left = left + "px"; panel.style.left = left + "px";
lastLeft = left; lastLeft = left;
@@ -218,10 +219,7 @@ class PanelResizer {
}) })
function handleWidthEvent(event) { function handleWidthEvent(event) {
var rect = panel.getBoundingClientRect(); let x;
var panelMaxX = rect.left + (startWidth || panel.style.maxWidth);
var x;
if(event) { if(event) {
x = event.clientX; x = event.clientX;
} else { } else {