From 7bb6363559da663e5eb76d94829042e4bf85c7d0 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Tue, 9 Nov 2021 07:00:21 +0100 Subject: [PATCH] Common code for splitter install. --- website/o3dv/js/navigator.js | 19 ++----------------- website/o3dv/js/sidebar.js | 19 ++----------------- website/o3dv/js/utils.js | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/website/o3dv/js/navigator.js b/website/o3dv/js/navigator.js index 97dd327..e1e540a 100644 --- a/website/o3dv/js/navigator.js +++ b/website/o3dv/js/navigator.js @@ -119,23 +119,8 @@ OV.Navigator = class } }); - let originalWidth = null; - OV.CreateVerticalSplitter (this.splitterDiv, { - onSplitStart : () => { - originalWidth = this.mainDiv.outerWidth (true); - }, - onSplit : (xDiff) => { - const minWidth = 280; - const maxWidth = 450; - let newWidth = originalWidth + xDiff; - if (newWidth < minWidth) { - newWidth = minWidth; - } else if (newWidth > maxWidth) { - newWidth = maxWidth; - } - this.mainDiv.outerWidth (newWidth, true); - this.callbacks.onResize (); - } + OV.InstallVerticalSplitter (this.splitterDiv, this.mainDiv, false, () => { + this.callbacks.onResize (); }); } diff --git a/website/o3dv/js/sidebar.js b/website/o3dv/js/sidebar.js index dda2798..deb5ca5 100644 --- a/website/o3dv/js/sidebar.js +++ b/website/o3dv/js/sidebar.js @@ -59,23 +59,8 @@ OV.Sidebar = class } ); - let originalWidth = null; - OV.CreateVerticalSplitter (this.splitterDiv, { - onSplitStart : () => { - originalWidth = this.mainDiv.outerWidth (true); - }, - onSplit : (xDiff) => { - const minWidth = 280; - const maxWidth = 450; - let newWidth = originalWidth - xDiff; - if (newWidth < minWidth) { - newWidth = minWidth; - } else if (newWidth > maxWidth) { - newWidth = maxWidth; - } - this.mainDiv.outerWidth (newWidth, true); - this.callbacks.onResize (); - } + OV.InstallVerticalSplitter (this.splitterDiv, this.mainDiv, true, () => { + this.callbacks.onResize (); }); } diff --git a/website/o3dv/js/utils.js b/website/o3dv/js/utils.js index e08e848..9001cb8 100644 --- a/website/o3dv/js/utils.js +++ b/website/o3dv/js/utils.js @@ -154,3 +154,30 @@ OV.CreateInlineColorCircle = function (color) let darkerColorHexString = '#' + OV.ColorToHexString (darkerColor); return $('
').addClass ('ov_color_circle').css ('background', hexString).css ('border', '1px solid ' + darkerColorHexString); }; + +OV.InstallVerticalSplitter = function (splitterDiv, resizedDiv, flipped, onResize) +{ + let originalWidth = null; + OV.CreateVerticalSplitter (splitterDiv, { + onSplitStart : () => { + originalWidth = resizedDiv.outerWidth (true); + }, + onSplit : (xDiff) => { + const minWidth = 280; + const maxWidth = 450; + let newWidth = 0; + if (flipped) { + newWidth = originalWidth - xDiff; + } else { + newWidth = originalWidth + xDiff; + } + if (newWidth < minWidth) { + newWidth = minWidth; + } else if (newWidth > maxWidth) { + newWidth = maxWidth; + } + resizedDiv.outerWidth (newWidth, true); + onResize (); + } + }); +};