aboutsummaryrefslogtreecommitdiff
path: root/src/client/goldenLayout.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/goldenLayout.js')
-rw-r--r--src/client/goldenLayout.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/client/goldenLayout.js b/src/client/goldenLayout.js
index 97ce13ae1..9cfea7f3f 100644
--- a/src/client/goldenLayout.js
+++ b/src/client/goldenLayout.js
@@ -1,4 +1,23 @@
(function ($) {
+ //if a tab is removed from the DOM and reinserted somewhere else all nested scrollTops seems to get reset to 0. (golden layout does this when a row structure needs to be converted to col or vice-versa)
+ const saveScrollTops = (element) => {
+ const children = Array.from(element.children());
+ while (children.length) {
+ const child = children.pop();
+ if (child.children) children.push(...(Array.from(child.children)));
+ if (child.scrollTop) child.preScrollTop = child.scrollTop;
+ }
+ }
+ const restoreScrollTops = (element) => {
+ const children = Array.from(element.children());
+ while (children.length) {
+ const child = children.pop();
+ if (child.children) children.push(...(Array.from(child.children)));
+ if (child.preScrollTop) {
+ child.scrollTop = child.preScrollTop;
+ }
+ }
+ }
var lm = { "config": {}, "container": {}, "controls": {}, "errors": {}, "items": {}, "utils": {} };
lm.utils.F = function () {
};
@@ -474,6 +493,8 @@
this._dragSources = [];
this._updatingColumnsResponsive = false;
this._firstLoad = true;
+ this.saveScrollTops = saveScrollTops;
+ this.restoreScrollTops = restoreScrollTops;
this.width = null;
this.height = null;
@@ -2064,6 +2085,7 @@
this.element.find('.lm_tab').attr('title', lm.utils.stripTags(this._contentItem.config.title));
this.element.find('.lm_title').html(this._contentItem.config.title);
this.childElementContainer = this.element.find('.lm_content');
+ saveScrollTops(contentItem.element);
this.childElementContainer.append(contentItem.element);
this._updateTree();
@@ -2071,6 +2093,7 @@
this._setDimensions();
$(document.body).append(this.element);
+ restoreScrollTops(contentItem.element);
var offset = this._layoutManager.container.offset();
@@ -2186,6 +2209,7 @@
this._contentItem._$destroy();
}
+ restoreScrollTops(this._contentItem.element)
this.element.remove();
this._layoutManager.emit('itemDropped', this._contentItem);
@@ -3211,7 +3235,10 @@
if (canDelete) {
rowOrCol.removeChild(stack);
if (rowOrCol.contentItems.length === 1 && parRowOrCol.contentItems.length === 1 && !parRowOrCol.isRoot) {
+
+ saveScrollTops(rowOrCol.contentItems[0].element);
parRowOrCol.replaceChild(rowOrCol, rowOrCol.contentItems[0]);
+ restoreScrollTops(rowOrCol.contentItems[0].element);
}
}
}