Common code for splitter install.

This commit is contained in:
kovacsv 2021-11-09 07:00:21 +01:00
parent 40cdc0a93d
commit 7bb6363559
3 changed files with 31 additions and 34 deletions

View File

@ -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 ();
});
}

View File

@ -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 ();
});
}

View File

@ -154,3 +154,30 @@ OV.CreateInlineColorCircle = function (color)
let darkerColorHexString = '#' + OV.ColorToHexString (darkerColor);
return $('<div>').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 ();
}
});
};