bwin 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/bwin.js +28 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Binary Window
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A lightweight window-tiling JavaScript library for the browser, featuring resizable panes, drag-and-drop, and more.
|
|
4
4
|
|
|
5
|
-
[
|
|
5
|
+
[Documentation](https://bhjsdev.github.io/bwin-docs/)
|
package/dist/bwin.js
CHANGED
|
@@ -121,8 +121,8 @@ function X(e, { clientX: t, clientY: i }) {
|
|
|
121
121
|
const n = e.getBoundingClientRect(), { width: s, height: o } = n, h = t - n.left, l = i - n.top;
|
|
122
122
|
if (h < 0 || h > s || l < 0 || l > o)
|
|
123
123
|
return r.Outside;
|
|
124
|
-
const a = 0.3,
|
|
125
|
-
return h < s * (0.5 - a / 2) && l >
|
|
124
|
+
const a = 0.3, d = _({ width: s, height: o, x: h }), c = U({ width: s, height: o, x: h }), g = k({ width: s, height: o, y: l }), u = Y({ width: s, height: o, y: l });
|
|
125
|
+
return h < s * (0.5 - a / 2) && l > d && l < c ? r.Left : h > s * (0.5 + a / 2) && l < d && l > c ? r.Right : l < o * (0.5 - a / 2) && h > g && h < u ? r.Top : l > o * (0.5 + a / 2) && h < g && h > u ? r.Bottom : h > s * (0.5 - a / 2) && h < s * (0.5 + a / 2) && l > o * (0.5 - a / 2) && l < o * (0.5 + a / 2) ? r.Center : r.Unknown;
|
|
126
126
|
}
|
|
127
127
|
const q = 100, j = 100, w = {
|
|
128
128
|
left: 0,
|
|
@@ -143,12 +143,12 @@ class p {
|
|
|
143
143
|
minHeight: h = w.minHeight,
|
|
144
144
|
domNode: l = null,
|
|
145
145
|
store: a = {},
|
|
146
|
-
position:
|
|
147
|
-
id:
|
|
146
|
+
position: d,
|
|
147
|
+
id: c
|
|
148
148
|
} = w) {
|
|
149
|
-
if (this.id =
|
|
149
|
+
if (this.id = c ?? z(), !d)
|
|
150
150
|
throw new Error("[bwin] Sash position is required");
|
|
151
|
-
this.position =
|
|
151
|
+
this.position = d, this.domNode = l, this._top = i, this._left = t, this._width = n, this._height = s, this.children = [], this.minWidth = o, this.minHeight = h, this.store = a;
|
|
152
152
|
}
|
|
153
153
|
walk(t) {
|
|
154
154
|
this.children.forEach((i) => i.walk(t)), t(this);
|
|
@@ -282,10 +282,10 @@ class p {
|
|
|
282
282
|
this._width = t;
|
|
283
283
|
const [n, s, o, h] = this.getChildren();
|
|
284
284
|
if (h && s) {
|
|
285
|
-
const l = h.width + s.width, a = i * (h.width / l),
|
|
286
|
-
let
|
|
285
|
+
const l = h.width + s.width, a = i * (h.width / l), d = l + i;
|
|
286
|
+
let c = h.width + a, g = d - c, u = s.left + a;
|
|
287
287
|
const E = h.calcMinWidth(), y = s.calcMinWidth();
|
|
288
|
-
i < 0 && (
|
|
288
|
+
i < 0 && (c < E && g > y ? (c = h.width, g = d - c, u = h.left + c) : g < y && c > E && (g = s.width, c = d - g, u = h.left + c)), h.width = c, s.width = g, s.left = u;
|
|
289
289
|
}
|
|
290
290
|
n && o && (n.width += i, o.width += i);
|
|
291
291
|
}
|
|
@@ -297,13 +297,13 @@ class p {
|
|
|
297
297
|
this._height = t;
|
|
298
298
|
const [n, s, o, h] = this.getChildren();
|
|
299
299
|
if (n && o) {
|
|
300
|
-
const l = n.height + o.height, a = i * (n.height / l),
|
|
301
|
-
let
|
|
300
|
+
const l = n.height + o.height, a = i * (n.height / l), d = l + i;
|
|
301
|
+
let c = n.height + a, g = d - c, u = o.top + a;
|
|
302
302
|
if (i < 0) {
|
|
303
303
|
const E = n.calcMinHeight(), y = o.calcMinHeight();
|
|
304
|
-
|
|
304
|
+
c < E && g > y ? (c = n.height, g = d - c, u = n.top + c) : g < y && c > E && (g = o.height, c = d - g, u = n.top + c);
|
|
305
305
|
}
|
|
306
|
-
n.height =
|
|
306
|
+
n.height = c, o.height = g, o.top = u;
|
|
307
307
|
}
|
|
308
308
|
h && s && (h.height += i, s.height += i);
|
|
309
309
|
}
|
|
@@ -322,13 +322,13 @@ class A {
|
|
|
322
322
|
minHeight: h,
|
|
323
323
|
position: l,
|
|
324
324
|
size: a,
|
|
325
|
-
...
|
|
325
|
+
...d
|
|
326
326
|
}) {
|
|
327
327
|
f(this, "left");
|
|
328
328
|
f(this, "top");
|
|
329
329
|
f(this, "width");
|
|
330
330
|
f(this, "height");
|
|
331
|
-
this.parentRect = t, this.children = i, this.siblingConfigNode = n, this.id = s, this.minWidth = o, this.minHeight = h, this.position = this.getPosition(l), this.size = this.getSize(a), this.nonCoreData =
|
|
331
|
+
this.parentRect = t, this.children = i, this.siblingConfigNode = n, this.id = s, this.minWidth = o, this.minHeight = h, this.position = this.getPosition(l), this.size = this.getSize(a), this.nonCoreData = d, this.setBounds();
|
|
332
332
|
}
|
|
333
333
|
getPosition(t) {
|
|
334
334
|
if (!this.siblingConfigNode)
|
|
@@ -702,13 +702,13 @@ const st = {
|
|
|
702
702
|
if (!this.isResizeStarted || !this.activeMuntinSash) return;
|
|
703
703
|
const [t, i, n, s] = this.activeMuntinSash.getChildren(), o = this.activeMuntinSash.isLeftRightSplit(), h = this.activeMuntinSash.isTopBottomSplit();
|
|
704
704
|
if (o && s && i) {
|
|
705
|
-
const l = e.pageX - this.lastX, a = s.width + l,
|
|
706
|
-
if (l > 0 &&
|
|
707
|
-
s.width = a, i.width =
|
|
705
|
+
const l = e.pageX - this.lastX, a = s.width + l, d = i.width - l;
|
|
706
|
+
if (l > 0 && d <= i.calcMinWidth() || l < 0 && a <= s.calcMinWidth()) return;
|
|
707
|
+
s.width = a, i.width = d, i.left = i.left + l, this.update(), this.lastX = e.pageX;
|
|
708
708
|
} else if (h && t && n) {
|
|
709
|
-
const l = e.pageY - this.lastY, a = t.height + l,
|
|
710
|
-
if (l > 0 &&
|
|
711
|
-
t.height = a, n.height =
|
|
709
|
+
const l = e.pageY - this.lastY, a = t.height + l, d = n.height - l;
|
|
710
|
+
if (l > 0 && d <= n.calcMinHeight() || l < 0 && a <= t.calcMinHeight()) return;
|
|
711
|
+
t.height = a, n.height = d, n.top = n.top + l, this.update(), this.lastY = e.pageY;
|
|
712
712
|
}
|
|
713
713
|
}), document.addEventListener("mouseup", () => {
|
|
714
714
|
this.isResizeStarted = !1, this.activeMuntinSash = null, this.revertResizeStyles();
|
|
@@ -805,12 +805,12 @@ function ut(e, t) {
|
|
|
805
805
|
const i = e.left + e.width, n = e.top + e.height, s = t.left + t.width, o = t.top + t.height;
|
|
806
806
|
if (e.left >= s || t.left >= i || e.top >= o || t.top >= n)
|
|
807
807
|
return null;
|
|
808
|
-
const h = Math.max(e.left, t.left), l = Math.max(e.top, t.top), a = Math.min(i, s),
|
|
808
|
+
const h = Math.max(e.left, t.left), l = Math.max(e.top, t.top), a = Math.min(i, s), d = Math.min(n, o);
|
|
809
809
|
return {
|
|
810
810
|
left: h,
|
|
811
811
|
top: l,
|
|
812
812
|
width: a - h,
|
|
813
|
-
height:
|
|
813
|
+
height: d - l
|
|
814
814
|
};
|
|
815
815
|
}
|
|
816
816
|
const ft = [ct, gt, dt], pt = {
|
|
@@ -827,17 +827,17 @@ const ft = [ct, gt, dt], pt = {
|
|
|
827
827
|
l > i && (i = l, n = s);
|
|
828
828
|
}
|
|
829
829
|
}), n) {
|
|
830
|
-
const s = e.bwOriginalPosition, o = P(n);
|
|
831
|
-
let
|
|
830
|
+
const s = e.bwOriginalPosition, o = P(n), h = n.getAttribute("sash-id"), l = this.rootSash.getById(h);
|
|
831
|
+
let a = 0;
|
|
832
832
|
if (s === r.Left || s === r.Right)
|
|
833
|
-
|
|
833
|
+
a = o.width - t.width < l.minWidth ? o.width / 2 : t.width;
|
|
834
834
|
else if (s === r.Top || s === r.Bottom)
|
|
835
|
-
|
|
835
|
+
a = o.height - t.height < l.minHeight ? o.height / 2 : t.height;
|
|
836
836
|
else
|
|
837
837
|
throw new Error("[bwin] Invalid position when restoring glass");
|
|
838
838
|
this.addPane(n.getAttribute("sash-id"), {
|
|
839
839
|
position: s,
|
|
840
|
-
size:
|
|
840
|
+
size: a
|
|
841
841
|
}).domNode.append(e.bwGlassElement);
|
|
842
842
|
}
|
|
843
843
|
},
|