0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

remove flickering in divider

This commit is contained in:
Víctor Losada Hernández
2024-10-27 10:20:49 +01:00
parent 782ee7a4ad
commit 391d0a0bfe
2 changed files with 5 additions and 6 deletions

View File

@@ -17,7 +17,6 @@ const SplitPane = (props)=>{
const [showMoveArrows, setShowMoveArrows] = useState(true);
const [liveScroll, setLiveScroll] = useState(false);
// Set initial divider position and liveScroll only after mounting
useEffect(()=>{
const savedPos = window.localStorage.getItem(storageKey);
setDividerPos(savedPos ? limitPosition(savedPos, 0.1 * (window.innerWidth - 13), 0.9 * (window.innerWidth - 13)) : window.innerWidth / 2);
@@ -29,6 +28,7 @@ const SplitPane = (props)=>{
const limitPosition = (x, min = 1, max = window.innerWidth - 13)=>Math.round(Math.min(max, Math.max(min, x)));
//when resizing, the divider should grow smaller if less space is given, then grow back if the space is restored, to the original position
const handleResize = () =>setDividerPos(limitPosition(window.localStorage.getItem(storageKey), 0.1 * (window.innerWidth - 13), 0.9 * (window.innerWidth - 13)));
const handleUp =(e)=>{
@@ -48,8 +48,7 @@ const SplitPane = (props)=>{
const handleMove = (e)=>{
if(!isDragging) return;
e.preventDefault();
const newSize = limitPosition(e.pageX);
setDividerPos(newSize);
setDividerPos(limitPosition(e.pageX));
};
const liveScrollToggle = ()=>{
@@ -75,7 +74,7 @@ const SplitPane = (props)=>{
);
const renderDivider = (
<div className='divider' onPointerDown={handleDown}>
<div className={`divider ${isDragging && 'dragging'}`} onPointerDown={handleDown}>
{showDividerButtons && renderMoveArrows}
<div className='dots'>
<i className='fas fa-circle' />
@@ -84,7 +83,7 @@ const SplitPane = (props)=>{
</div>
</div>
);
return (
<div className='splitPane' onPointerMove={handleMove} onPointerUp={handleUp}>
<Pane width={dividerPos} moveBrew={moveBrew} moveSource={moveSource} liveScroll={liveScroll} setMoveArrows={setShowMoveArrows}>

View File

@@ -30,7 +30,7 @@
color : #666666;
}
}
&:hover { background-color : #999999; }
&:hover,&.dragging { background-color : #999999; }
}
.arrow {
position : absolute;