lilact 0.26.0 → 0.26.1
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/dist/lilact.development.js +46 -17
- package/dist/lilact.development.js.map +3 -3
- package/dist/lilact.development.min.js +23 -23
- package/dist/lilact.development.min.js.map +3 -3
- package/dist/lilact.production.min.js +23 -23
- package/docs/functions/timers.timeoutPromise.html +1 -1
- package/docs/static/lilact.development.js +46 -17
- package/docs/static/lilact.development.js.map +3 -3
- package/docs/static/lilact.development.min.js +23 -23
- package/docs/static/lilact.development.min.js.map +3 -3
- package/docs/static/lilact.production.min.js +23 -23
- package/docs/variables/accessories.SplitPane.html +1 -1
- package/examples/lilact.development.js +46 -17
- package/examples/lilact.development.js.map +3 -3
- package/examples/lilact.development.min.js +23 -23
- package/examples/lilact.development.min.js.map +3 -3
- package/examples/lilact.production.min.js +23 -23
- package/package.json +1 -1
- package/src/accessories.jsx +59 -22
package/package.json
CHANGED
package/src/accessories.jsx
CHANGED
|
@@ -420,7 +420,7 @@ export function DragHandle({
|
|
|
420
420
|
* @param max - Maximum allowed position. Defaults to `0.9`.
|
|
421
421
|
Can also be a function that will be called with (containerWidth|containerHeight,splitterSize) as arguments
|
|
422
422
|
* @param splitterSize - Thickness of the draggable splitter in pixels. Defaults to `8`.
|
|
423
|
-
* @param
|
|
423
|
+
* @param resizePolicy - The behavior on container resize. Its value can be `proportional`, `fixFirst` or `fixSecond`.
|
|
424
424
|
* Default is `proportional`.
|
|
425
425
|
* @param onSizeChange - Callback invoked when the position changes. Receives the new normalized position.
|
|
426
426
|
* @param style - Optional root container styles.
|
|
@@ -457,7 +457,7 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
457
457
|
max = 0.9,
|
|
458
458
|
splitterSize = 8,
|
|
459
459
|
onSizeChange,
|
|
460
|
-
|
|
460
|
+
resizePolicy = "proportional",
|
|
461
461
|
style,
|
|
462
462
|
className,
|
|
463
463
|
firstPaneStyle,
|
|
@@ -517,24 +517,61 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
517
517
|
sizeRef.current = { w: rect.width, h: rect.height };
|
|
518
518
|
|
|
519
519
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
if(internalMode==='vertical'
|
|
531
|
-
|
|
520
|
+
const EPS = 1e-6;
|
|
521
|
+
|
|
522
|
+
function clamp01(x) {
|
|
523
|
+
return Math.min(1, Math.max(0, x));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (ref.current?.getPosition) {
|
|
527
|
+
const p = ref.current.getPosition();
|
|
528
|
+
|
|
529
|
+
if (resizePolicy === 'fixFirst') {
|
|
530
|
+
if (internalMode === 'vertical') {
|
|
531
|
+
const availOld = o.h - splitterSize;
|
|
532
|
+
const availNew = sizeRef.current.h - splitterSize;
|
|
533
|
+
if (availOld > 0 && availNew > 0) {
|
|
534
|
+
const firstPx = p * availOld; // fixed pane size in px
|
|
535
|
+
const nextP = firstPx / availNew; // recompute normalized
|
|
536
|
+
if (Math.abs(nextP - p) > EPS) setPosition(clamp01(nextP));
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
const availOld = o.w - splitterSize;
|
|
541
|
+
const availNew = sizeRef.current.w - splitterSize;
|
|
542
|
+
if (availOld > 0 && availNew > 0) {
|
|
543
|
+
const firstPx = p * availOld;
|
|
544
|
+
const nextP = firstPx / availNew;
|
|
545
|
+
if (Math.abs(nextP - p) > EPS) setPosition(clamp01(nextP));
|
|
546
|
+
}
|
|
532
547
|
}
|
|
533
|
-
|
|
534
|
-
|
|
548
|
+
}
|
|
549
|
+
else if (resizePolicy === 'fixSecond') {
|
|
550
|
+
// fixSecond means second pane pixel size stays constant.
|
|
551
|
+
// secondPx = (1-p) * availOld
|
|
552
|
+
// nextP = 1 - secondPx/availNew
|
|
553
|
+
if (internalMode === 'vertical') {
|
|
554
|
+
const availOld = o.h - splitterSize;
|
|
555
|
+
const availNew = sizeRef.current.h - splitterSize;
|
|
556
|
+
if (availOld > 0 && availNew > 0) {
|
|
557
|
+
const secondPx = (1 - p) * availOld;
|
|
558
|
+
const nextP = 1 - (secondPx / availNew);
|
|
559
|
+
if (Math.abs(nextP - p) > EPS) setPosition(clamp01(nextP));
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
const availOld = o.w - splitterSize;
|
|
564
|
+
const availNew = sizeRef.current.w - splitterSize;
|
|
565
|
+
if (availOld > 0 && availNew > 0) {
|
|
566
|
+
const secondPx = (1 - p) * availOld;
|
|
567
|
+
const nextP = 1 - (secondPx / availNew);
|
|
568
|
+
if (Math.abs(nextP - p) > EPS) setPosition(clamp01(nextP));
|
|
569
|
+
}
|
|
535
570
|
}
|
|
536
571
|
}
|
|
537
572
|
}
|
|
573
|
+
|
|
574
|
+
|
|
538
575
|
});
|
|
539
576
|
|
|
540
577
|
ro.observe(el);
|
|
@@ -542,7 +579,7 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
542
579
|
sizeRef.current = { w: rect.width, h: rect.height };
|
|
543
580
|
|
|
544
581
|
return () => ro.disconnect();
|
|
545
|
-
}, [
|
|
582
|
+
}, [resizePolicy, internalMode]);
|
|
546
583
|
|
|
547
584
|
const startPosRef = useRef(posResolved);
|
|
548
585
|
const [dragging, setDragging] = useState(false);
|
|
@@ -606,7 +643,7 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
606
643
|
computedPane1Style.bottom = 0;
|
|
607
644
|
computedPane2Style.top = 0;
|
|
608
645
|
|
|
609
|
-
if(
|
|
646
|
+
if(resizePolicy==='fixFirst') {
|
|
610
647
|
computedPane1Style.width = p*(w-splitterSize);
|
|
611
648
|
computedPane2Style.left = computedPane1Style.width+splitterSize;
|
|
612
649
|
|
|
@@ -617,14 +654,14 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
617
654
|
width: splitterSize,
|
|
618
655
|
});
|
|
619
656
|
}
|
|
620
|
-
else if(
|
|
657
|
+
else if(resizePolicy==='fixSecond') {
|
|
621
658
|
computedPane2Style.width = (1-p)*(w-splitterSize);
|
|
622
659
|
computedPane1Style.right = computedPane2Style.width+splitterSize;
|
|
623
660
|
|
|
624
661
|
Object.assign( computedSplitterStyle, {
|
|
625
662
|
top: 0,
|
|
626
663
|
bottom: 0,
|
|
627
|
-
|
|
664
|
+
right: computedPane2Style.width,
|
|
628
665
|
width: splitterSize,
|
|
629
666
|
});
|
|
630
667
|
}
|
|
@@ -644,7 +681,7 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
644
681
|
computedPane1Style.right = 0;
|
|
645
682
|
computedPane2Style.left = 0;
|
|
646
683
|
|
|
647
|
-
if(
|
|
684
|
+
if(resizePolicy==='fixFirst') {
|
|
648
685
|
computedPane1Style.height = p*(h-splitterSize);
|
|
649
686
|
computedPane2Style.top = computedPane1Style.height+splitterSize;
|
|
650
687
|
|
|
@@ -655,7 +692,7 @@ export const SplitPane = forwardRef(function SplitPane(
|
|
|
655
692
|
height: splitterSize,
|
|
656
693
|
});
|
|
657
694
|
}
|
|
658
|
-
else if(
|
|
695
|
+
else if(resizePolicy==='fixSecond') {
|
|
659
696
|
computedPane2Style.height = (1-p)*(h-splitterSize);
|
|
660
697
|
computedPane1Style.bottom = computedPane2Style.height+splitterSize;
|
|
661
698
|
|