From e2b0df8e1d91578af7b97fb36bd029104a51dd01 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 25 Mar 2021 21:13:11 -0400
Subject: from last

---
 .../views/collections/CollectionDockingView.tsx    | 29 +++-------------------
 1 file changed, 4 insertions(+), 25 deletions(-)

(limited to 'src/client/views/collections/CollectionDockingView.tsx')

diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index ec34f1260..7e89cf55d 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -162,27 +162,6 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
         if (!instance) return false;
         const docContentConfig = CollectionDockingView.makeDocumentConfig(document, panelName);
 
-        //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: any) => {
-            const children = Array.from(element.children()) as any[];
-            while (children.length) {
-                const child = children.pop();
-                if (child.children) children.push(...(Array.from(child.children) as any[]));
-                if (child?.scrollTop) child.preScrollTop = child.scrollTop;
-            }
-        }
-        const restoreScrollTops = (element: any) => {
-            const children = Array.from(element.children()) as any[];
-            while (children.length) {
-                const child = children.pop();
-                if (child.children) children.push(...(Array.from(child.children) as any[]));
-                if (child?.preScrollTop) {
-                    child.scrollTop = child.preScrollTop;
-                    child.preScrollTop = undefined;
-                }
-            }
-        }
-
         if (!pullSide && stack) {
             stack.addChild(docContentConfig, undefined);
             stack.setActiveContentItem(stack.contentItems[stack.contentItems.length - 1]);
@@ -210,7 +189,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
                         const rowlayout = instance._goldenLayout.root.contentItems[0];
                         const newColumn = rowlayout.layoutManager.createContentItem({ type: "column" }, instance._goldenLayout);
 
-                        saveScrollTops(rowlayout.element);
+                        CollectionDockingView.Instance._goldenLayout.saveScrollTops(rowlayout.element);
                         rowlayout.parent.replaceChild(rowlayout, newColumn);
                         if (pullSide === "top") {
                             newColumn.addChild(rowlayout, undefined, true);
@@ -219,7 +198,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
                             newColumn.addChild(newContentItem, undefined, true);
                             newColumn.addChild(rowlayout, 0, true);
                         }
-                        restoreScrollTops(rowlayout.element);
+                        CollectionDockingView.Instance._goldenLayout.restoreScrollTops(rowlayout.element);
 
                         rowlayout.config.height = 50;
                         newContentItem.config.height = 50;
@@ -235,7 +214,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
                         const collayout = instance._goldenLayout.root.contentItems[0];
                         const newRow = collayout.layoutManager.createContentItem({ type: "row" }, instance._goldenLayout);
 
-                        saveScrollTops(collayout.element);
+                        CollectionDockingView.Instance._goldenLayout.saveScrollTops(collayout.element);
                         collayout.parent.replaceChild(collayout, newRow);
                         if (pullSide === "left") {
                             newRow.addChild(collayout, undefined, true);
@@ -244,7 +223,7 @@ export class CollectionDockingView extends CollectionSubView(doc => doc) {
                             newRow.addChild(newContentItem, undefined, true);
                             newRow.addChild(collayout, 0, true);
                         }
-                        restoreScrollTops(collayout.element);
+                        CollectionDockingView.Instance._goldenLayout.restoreScrollTops(collayout.element);
 
                         collayout.config.width = 50;
                         newContentItem.config.width = 50;
-- 
cgit v1.2.3-70-g09d2

