mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-31 10:22:36 +01:00
Add context menu freeze on hover
This commit is contained in:
parent
39c2fd4246
commit
924ea0de68
@ -28,7 +28,7 @@ export const ContextMenuView: FC<ContextMenuViewProps> = props =>
|
|||||||
const [ opacity, setOpacity ] = useState(1);
|
const [ opacity, setOpacity ] = useState(1);
|
||||||
const [ isFading, setIsFading ] = useState(false);
|
const [ isFading, setIsFading ] = useState(false);
|
||||||
const [ fadeTime, setFadeTime ] = useState(0);
|
const [ fadeTime, setFadeTime ] = useState(0);
|
||||||
const [ frozen, setFrozen ] = useState(false);
|
const [ isFrozen, setIsFrozen ] = useState(false);
|
||||||
const elementRef = useRef<HTMLDivElement>();
|
const elementRef = useRef<HTMLDivElement>();
|
||||||
|
|
||||||
const getOffset = useCallback((bounds: NitroRectangle) =>
|
const getOffset = useCallback((bounds: NitroRectangle) =>
|
||||||
@ -156,7 +156,7 @@ export const ContextMenuView: FC<ContextMenuViewProps> = props =>
|
|||||||
{
|
{
|
||||||
let added = false;
|
let added = false;
|
||||||
|
|
||||||
if(!frozen)
|
if(!isFrozen)
|
||||||
{
|
{
|
||||||
added = true;
|
added = true;
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ export const ContextMenuView: FC<ContextMenuViewProps> = props =>
|
|||||||
{
|
{
|
||||||
if(added) GetTicker().remove(update);
|
if(added) GetTicker().remove(update);
|
||||||
}
|
}
|
||||||
}, [ frozen, update ]);
|
}, [ isFrozen, update ]);
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
@ -178,5 +178,5 @@ export const ContextMenuView: FC<ContextMenuViewProps> = props =>
|
|||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
}, [ fades ]);
|
}, [ fades ]);
|
||||||
|
|
||||||
return <Base innerRef={ elementRef } position={ position } classNames={ getClassNames } style={ getStyle } { ...rest } />;
|
return <Base innerRef={ elementRef } position={ position } classNames={ getClassNames } style={ getStyle } onMouseOver={ event => setIsFrozen(true) } onMouseOut={ event => setIsFrozen(false) } { ...rest } />;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user