mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 13:49:59 +02:00
Fix resizing of draggable window
This commit is contained in:
parent
6ade130b40
commit
4d40fb8202
1 changed files with 17 additions and 8 deletions
|
@ -55,19 +55,28 @@ var gZenBrowserManagerSidebar = {
|
||||||
const maxSize = parseInt(computedStyle.getPropertyValue(`max-${direction}`).match(/(\d+)px/)?.[1]) || Infinity;
|
const maxSize = parseInt(computedStyle.getPropertyValue(`max-${direction}`).match(/(\d+)px/)?.[1]) || Infinity;
|
||||||
const minSize = parseInt(computedStyle.getPropertyValue(`min-${direction}`).match(/(\d+)px/)?.[1]) || 0;
|
const minSize = parseInt(computedStyle.getPropertyValue(`min-${direction}`).match(/(\d+)px/)?.[1]) || 0;
|
||||||
|
|
||||||
const sidebarSize = this.sidebar.getBoundingClientRect()[direction];
|
const sidebarSizeStart = this.sidebar.getBoundingClientRect()[direction];
|
||||||
|
|
||||||
const startPos = mouseDownEvent[`screen${axis}`];
|
const startPos = mouseDownEvent[`screen${axis}`];
|
||||||
|
|
||||||
|
const toAdjust = isHorizontal ? "top" : "left";
|
||||||
|
const sidebarPosStart = parseInt(this.sidebar.style[toAdjust].match(/\d+/));
|
||||||
|
|
||||||
let mouseMove = function (e) {
|
let mouseMove = function (e) {
|
||||||
let moved = e[`screen${axis}`] - startPos;
|
let mouseMoved = e[`screen${axis}`] - startPos;
|
||||||
if (reverse) moved *= -1;
|
if (reverse) {
|
||||||
let newSize = sidebarSize + moved;
|
mouseMoved *= -1;
|
||||||
let currentMax = maxSize;
|
}
|
||||||
if (maxSize === Infinity) {
|
let newSize = sidebarSizeStart + mouseMoved;
|
||||||
currentMax = this.sidebarWrapper.getBoundingClientRect()[direction];
|
let currentMax = maxSize;
|
||||||
|
const wrapperBox = this.sidebarWrapper.getBoundingClientRect();
|
||||||
|
const maxWrapperSize = reverse ? (sidebarPosStart + sidebarSizeStart) : (wrapperBox[direction] - sidebarPosStart);
|
||||||
|
newSize = Math.max(minSize, Math.min(currentMax, maxWrapperSize,newSize));
|
||||||
|
|
||||||
|
if (reverse) {
|
||||||
|
const actualMoved = newSize - sidebarSizeStart;
|
||||||
|
this.sidebar.style[toAdjust] = (sidebarPosStart - actualMoved) + "px";
|
||||||
}
|
}
|
||||||
newSize = Math.max(minSize, Math.min(currentMax, newSize));
|
|
||||||
this.sidebar.style[direction] = `${newSize}px`;
|
this.sidebar.style[direction] = `${newSize}px`;
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue